Using Lightswitch with my own Domain object : missing reference - silverlight

I'm working on an asp.net application. I have a Domain assembly (containing mostly command and queries code), a Domain.Contract assembly ( containing mostly the domain objets), a Repository (called by the Domain) and the Web site.
For some specific backoffice needs, I want to create a Lightswitch application. I want to use my current domain as a datasource. I added a WCF Ria Service class Library, and in the RiaService.Web project, added a class based on DomainService, with one query method. Nothing more (no entities, since they are in my Domain.Contract assembly)
Using help from here (thanks Michael W), I was able to add the datasource, and to get my domain object recognized as an entity in light switch.
But, I now have a compile error : 'The type or namespace name 'MyDomain' could not be found in the global namespace (are you missing an assembly reference?)' in the project ServerGenerated.
The specific error is on this line :
global::Domain.Contract.MyObject result = new global::Domain.Contract.MyObject();
which is on of my domain objects (created in my Domain.Contract assembly).
So, it seems that the only thing I need to do is to add a reference do Domain.contract to the ServerGenerated project.
But it does not appear in Visual Studio. Adding my reference to the Server project does not fix the error.
Thanks.

In your solution explorer windows, select the ServerGenerated assembly and click on the "show all files" button. This will show all hidden folders - including the generated client code for WCF Ria.
If there's no generated code this means there's either something wrong with the service implementation (typically you'd get a compilation error) or there's something else wrong with the service - like a missing [EnableClientAccess] attribute (I know for a fact that a service without this attribute does not generate client code).
Other things to check for is to include the server-side ria assembly in your host project + have a correct configuration for WCF ria in the .config file (ask google).

In your solution explorer windows, select the project and click on the "show all files" button and also select the "file view" (not the logical view).
Then add the reference to the projet "ServerGenerated" (not the server project)

Related

Error while adding project

I'm trying to create a new solution with dot net nuke.
I installed the packages and configured IIS to work with it.
Then with visual studio i created a new solution. I want to import an old module already created, so i copied/pasted the folder in "DesktopModules".
Then with VS i right click on the solution and selects add existing project.
This way i get an error:
The web application project "name" is configured to use IIS. The web server "http://dnndev.me/desktopmodules/name" is not found.
It's probably because the corresponding projet is configured to use a web server depending on the URL you've got.
I suggest you to edit the project file with notepad (csproj or vbproj) and to remove the specified URL configuration. You also have to set the UseIIS value to false.
Note that this configuration could be stored in the users project file (.vbproj.user or .csproj.user).
Then, try again to add this project to your solution.

WCF - WSDL not updating when publishing service

I added a DataContract to my service and tried updating the service reference to get access to that DataContract. But it never showed up in the intellisense. I cleaned and built the project and then updated the service reference, but it still didn't work.
I then published it to the server and updated the service reference so it would point to the server, but I get the same thing. I browsed the service through IIS and opened my service in the browser.
I clicked the top link that had Service.svc?wsdl to see if my DataContract was there. An old MessageContract was there, but the DataContract was not.
Any ideas on what I'm doing wrong here?
Delete the currently deployed service binaries and verify that the service is inaccessible. Then deploy the new service binaries. This is to verify you're actually deploying to the correct location.
It is also possible that the service binaries aren't being rebuilt. To verify this, delete your bin folder (located next to your project file generally) and issue a rebuild, then follow the first steps.
I got my answer from here.
Only the types actually used by the service will be reflected in the metadata.
I didn't have an operation contract that used the DataContract. I didn't need to have one at the time, so I didn't make it. But apparently, unless you have one that uses it, the metadata won't be generated for that DataContract.

Salesforce .Enterprise WSDL in .net integration (Generate .Net stub code from salesforce enterprise WSDL)

I created Enterprise WSDL from SFDC and saved it on local machine.
When I add a web reference in VS 2008 it just add a reference to wsdl it does not generate a stub code ( code class) I also tried by using 'Add Service Reference' and 'Add Service Reference'--> Advanced --> Add Web Reference.
Can you please comment on this, what I am missing and How I can generate a C# code from Enterprise WSDL.
Thanks.
Your question are not clear enought. After adding a web reference, u should be abe to call it just by typing the namespace/reference. Something like var service = new EnterpriseWSDL.SforceService(); If u are having trouble to add the web reference to the project, try to put the .wsdl on c:\inetpub\wwwroot besides the project folder.
please put your local wsdl service physical path
like as
Add Service Reference'--> Advanced --> Add Web Reference-->C:\ramki\test.wsdl

Silverlight web service call not even hitting servers

I have a custom proxy class for a single WCF web-service (takes a string in, sends a string back). The asynchronous web service call works great from my Windows Form app. However, when I call it from a test Silverlight app I get an error: Hresult 0x80000012. This error is for Extension Attributes on files I believe... Go figure.
Using Fiddler I can confirm that no traffic is making it to IIS which is hosting the service, so it isn't the usual cross-domain restriction issue. I've tried using both "localhost" (which works in the Windows Forms app) and a name defined in my hosts file just in case "localhost" was causing the problem.
I've tested it by making the async call from the UI thread and also from a thread-pool queue item with the same results.
The proxy code is basically just simplified down from what the MS proxy generator creates, setting up bindings and settings programatically instead of via config files, and I use basically the same source to compile normal .Net and Silverlight versions of the libraries involved. (Now, the MS proxy code it is based on is from a WCF web service, not from the RIA template code, so maybe there are differences there...)
Four days of fruitless search on this one. Any help or suggestions would be wildly appreciated!
Figured it out. I was using (stupidly) a backslash in part of the URL that I used to set up the service call. Most of the interior parts of the MS code handled that ok and transposed them to forward slashes -- on Windows Forms everything worked seamlessly in fact. However, the Silverlight libraries couldn't handle it and threw the very helpful "HResult 0x80000012" error.
Changing my backslashes to slashes seems to have fixed the problem!

WPF to WCF Permission issue

I have created a WPF browser application that I wish to connect to a WCF service. The service is in the same solution as the WPF application. It is the default service that Visual Studio creates with a method called GetData (int)
I am attempting to call this service with the following code:
var client = new Service1.Service1Client();
client.GetData(10);
I get the following error on the above line (client.GetData(10);)
{"Request for the permission of type 'System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."}
Please help
This solution from Scott Lanford worked for me:
http://www.codeexperiment.com/post/Debugging-XBAPWCF-Applications.aspx
Quote:
The possible reasons for this error are numerous but in this case it was because the default Debug->Start Action for an XBAP project is "Start browser in URL", where the URL simply points to the .xbap file on disk (e.g. C:\projects\myproject\bin\debug\myproject.xbap).
For a partial trust XBAP application to communicate with a WCF service it must be deployed from the same domain and port as the WCF service. The way to solve this dilemma is to fake the XBAP URL by starting the XBAP application with PresentationHost.exe and supplying the XBAP URL (copied from the "Start browser with URL" value) via the debug parameter and the WCF service URL via the debugSecurityZoneURL parameter.
For example the debugging options for your XBAP project should look something like this:
Start Action -> Start external program = %windir%\system32\PresentationHost.exe
Start Options -> Command line arguments = -debug "c:\projects\myproject\bin\debug\MyProject.xbap" -debugSecurityZoneUrl "http://localhost:2022"
You need to setup a client access policy on the server. Running in the browser comes with a bunch of security limitations.
I think this article should get you the information you need, http://www.dotnetcurry.com/ShowArticle.aspx?ID=208&AspxAutoDetectCookieSupport=1.

Resources