Skip to main content
Home Forums Silverlight Programming Programming with .NET - General RC0 - Having Trouble creating Proxy for Silverlight-enabled WFC Service.
10 replies. Latest Post by Ed Smith on October 23, 2008.
(0)
dbaechtel
Member
59 points
207 Posts
09-28-2008 2:35 PM |
I am trying to create a Silverlight 2 RC0 project that accesses a Silverlight-enabled WFC Service in VB.Net. The online documentation seems to be outdated and does not work. I created a New Silverlight Project as a New ASP.New Project. The the default Project I added a New Silverlight-enabled WCF project called service1. I got a Visual Studio error when I did this that said "Error, Object Reference not set to an instance of an object." But the action seemed to go OK, the Service was added and the Project compiled OK. Next to my Project I executed an "Add Service Reference" to the default DoWork operation. That operation seemed to go OK and ServiceRefernce1 was added. The problem is how to define a proxy in the page.xaml.vb file to access the DoWork service. To the project I added References to System.ServiceModel and System.ServiceModel.Web. To my Page.xaml.vb file I can add Imports for System.ServiceModel and System.ServiceModel.Channels. To my Page.New() after InitializeComponent() I add "Dim proxy = new SilverlightApplication6.Web.ServiceReference1.Service1Client" which the compiler says is not defined. Service1Client is defined in the Object Browser but I can not find a way to reference it in my Page.xaml.vb file. Intellisense gives me no clue. It will not allow me to add a Reference for SilverlightApplication6.Web to the project. So, how do I reference the default Silverlight-enabled WCF Service operation DoWork in my Silverlight 2 RC0 Page.xaml.vb file ? Where is the new documentation that shows how to get this to work? THANKS for any assistance.
ken tucker
All-Star
16198 points
2,470 Posts
09-28-2008 6:21 PM |
I thought this bug would have been fixed but in the servicereferences.clientconfig file in the silverlight app make sure your project name is in the contract. This is what is auto generated
<configuration> <system.serviceModel> <bindings> <basicHttpBinding> <binding name="BasicHttpBinding_Service1" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"> <security mode="None" /> </binding> </basicHttpBinding> </bindings> <client> <endpoint address="http://localhost:2822/Service1.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_Service1" contract="ServiceReference1.Service1" name="BasicHttpBinding_Service1" /> </client> </system.serviceModel></configuration>
But this is what is needed for it to work
<configuration> <system.serviceModel> <bindings> <basicHttpBinding> <binding name="BasicHttpBinding_Service1" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"> <security mode="None" /> </binding> </basicHttpBinding> </bindings> <client> <endpoint address="http://localhost:2822/Service1.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_Service1" contract="SilverlightApplication10.ServiceReference1.Service1" name="BasicHttpBinding_Service1" /> </client> </system.serviceModel></configuration>
09-29-2008 8:32 AM |
Unfortunately the code that you sent doesn't work either with SL 2 RC0. It gets a runtime exception.
fkhoury
10 points
8 Posts
10-15-2008 5:17 AM |
i have a WCF service, and the proxy is not being generated for me neither. I'm using RC1
i have investigated the problem and i have found that the Reference.cs file is empty.
Anyone else is experiencing this behavior?
How can we work around it?
brauliod
Participant
1169 points
472 Posts
10-15-2008 5:48 AM |
Hello,
On Beta 2 there were some hidden issues when installing SL2 Dev Tools, the thing is that in some cases there's a webservice library that is more up to date that the one is needed to install,
Take a look at the bottom of this thread:
http://silverlight.net/forums/p/21440/82267.aspx#82267
HTH
Braulio
Ed Smith
6 points
3 Posts
10-16-2008 3:35 PM |
I think Ken's reply is address a different issue we had during the beta, that we fixed during the final release.
I have a couple of questions, to help me try to reproduce this (it doesn't happen on my machine).
dbaechtel, if you open the reference.vb file(turn on show all files in the solution explorer), is it empty like what fkhoury is seeing in his response. I assume it is not because you can see it in the object browser. You shouldn't need to add references to system.servicemodel or anything, that should be added automatically when you add the service reference. To call it you should be able to just call "dim proxy as new ServiceReference1.ServiceClient". It is not under the web namespace. then you can call proxy. I included some sample steps below
Do you have team foundation server installed by any chance?
fkhoury, can you check to see if you have any compile warnings or errors? If you are trying to add a service reference to a regular wcf service (one the use wsHttpBinding, not a Silverlight enabled wcf service(one the uses basicHttpBinding), then this is not supported, but you should have a compiler warning.
Here are some sample steps to get a basic Silverlight app working (in vb)
Create new vb Silverlight app
Add Silverlight enabled wcf service to project
Build
Add service reference
Add <TextBlock x:Name="t1" Text="Hello, Ed" /> to page.xaml and the following code to the code behind
Public Sub New()
InitializeComponent()
client = New ServiceReference1.Service1Client()
client.DoWorkAsync()
End Sub
Dim WithEvents client As ServiceReference1.Service1Client
Public Sub test(ByVal sender As Object, ByVal e As ComponentModel.AsyncCompletedEventArgs) Handles client.DoWorkCompleted
t1.Text = "completed"
Hope this helps,
-Ed Smith
Microsoft Visual Studio team
10-17-2008 2:03 PM |
Hi Ed,
Im not able to generate the proxy anymore (event with an empty reference.cs file) because VS.net is crashing during the generation of the proxy before getting to the stage of creating the cs file. i reinstalled silverlight tools and the problem is still the same. The same problem is happening with a colleage of mine, we both have TFS installed, but im making sure that everything is checked out before creating the proxy, and im always providing a new name for the proxy.
I'll try your solution in a separate solution and tell you about the result.
Thank you,Fadi KHOURY
10-17-2008 2:56 PM |
Thanks Fadi,
Try out the scenario I sent, and see if that works for you. I'm trying to figure out if somehow you got a bad install or if this is just a bug in the product code. How did you install VS, tfs, sp1, and silverlight (In what order). Did you uninstall anything including any prior versions.
You can email me the dump for the crash and we can take a look. Can you try to run the web service in the browser(right click on the svc in solution explorer and choose view in browser, then when IE comes up, click on the link to the ?wsdl file) and include the wsdl file in the email.
You can also try to generate the proxy using slsvcutil.exe. This is the command line tool that does what the add service reference dialog does in VS.
10-21-2008 5:16 AM |
I tried the scenario and it worked, althougth i got a message when creating the silverlight enabled WCF Service. it said "Object reference not set as an instance of an object", but then the proxy was genrated successfully and i could call it.
I installed VS,TFS,SP1, Silverlight in this order. On one machine, i have uninstalled everything even VS, and then reinstalled it on another drive. but on the second machine i just unistalled the old version of silverlight. Both machines have the same problem.
The Breaking News is that today i tried to generate the proxy from another silverlight project in the same solution and it worked! The first silverlight project still breaks on generating the proxy. Now, This looks more like a csproj problem rather than an installation problem.
Regards,Fadi KHOURY
10-21-2008 10:05 AM |
Problem Resolved.
After a lot of trial and errors, i found the cause of the crash. it is weird but true, once you add a reference to C1.Silverlight.RichTextBox, VS.net will crash on generating a WCF proxy. Everytime, i want to update the proxy, i remove the reference to this DLL and then add it again before compiling the project.
you can find this DLL here http://forums.componentone.com/CS/forums/storage/78/209781/C1.Silverlight%20M5%20Preview%20(RC0%20compatbile%20-%20unstable%20version).zip
10-23-2008 1:00 PM |
Thanks. I got your repro and we are investigating it.
The trouble happens when we try to load the types from the dll, we are doing this because you have type sharing turned on (we search your projects assemblies for types that match the types in your service). If you turn off type sharing (in the advanced dialog) or just uncheck this dll, then you will not run into this problem.
Microsoft Visual Studio