Showing posts with label WCF. Show all posts
Showing posts with label WCF. Show all posts

Thursday, November 15, 2007

Programmatically enumerate WCF endpoints defined in app.config

For various reasons you might want to enumerate all client endpoints defined in the application configuration file.

For future reference, this is one way to do it:

// Automagically find all client endpoints defined in app.config
ClientSection clientSection =
ConfigurationManager.GetSection("system.serviceModel/client") as ClientSection;

ChannelEndpointElementCollection endpointCollection =
clientSection.ElementInformation.Properties[string.Empty].Value as ChannelEndpointElementCollection;
List<string> endpointNames = new List<string>();
foreach (ChannelEndpointElement endpointElement in endpointCollection)
{
endpointNames.Add(endpointElement.Name);
}
// use endpointNames somehow ...

..obviously this is not production quality code.

Tuesday, November 28, 2006

.NET 3.0 artikelserie fortsättning

Del 4 och 5 är skrivna på pellesoft och kommer att släppas inom kort. Denna gång handlar det om WPF.

Technorati tags: , ,

Thursday, November 23, 2006

Implicit UseSynchronizationContext==true may lead to deadlocks ...

Today I found a little gem on Mahjayar's blog on the use of CallbackBehavior and UseSynchronizationContext. Basically, if you have a duplex contract you might want to switch off UseSynchronization context, particularly if the client is WinForms (or WPF), or you might end up with deadlocks.

Technorati tags:

Tuesday, November 21, 2006

.NET 3.0 artikelserie på gång

Har börjat skriva en artikelserie om .NET 3.0 på pellesoft.

Del 1, 2, 3 redan klara och handlar främst om WCF. Nästa i tur är ytskrap av WPF. Del 1 släpptes idag. Del 2 kommer i morgon och del 3 i övermorgon.

Technorati tags: , ,

Tuesday, November 07, 2006

Tuesday, September 12, 2006

Oh the joys of UAC (NOT)

Tried to do a little bughunting on a WCF project, the problem specifically related to dual bindings. However, I did not get so far, since I soon found out through "trial and horror" that in Vista you are not allowed to bind to a port unless running under elevated privileges.

Yes, UAC strikes once again!

I soon found out that this is a known issue and how you should work around it. Basically you add a manifest to the exe requesting elevated privileges.




<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestversion="1.0">
<trustinfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedprivileges>
<requestedexecutionlevel level="requireAdministrator">
</requestedprivileges>
</security>
</trustinfo>
</assembly>


However, I couldn't get this working under a debugger !?! (The manifest is there as both exename.exe.manifest and exename.vshost.exe.manifest)

So, how is one supposed to debug a WCF server on Vista !?!

Thursday, September 07, 2006

Developing WCF without Orcas CTP

For various reasons I installed the .NET 3.0 RC1 Runtime/SDK as soon as they were available. This meant that I didn't have a CTP of Orcas to go with it. As I currently don't have any WPF stuff to do I figured I'd manage just as fine without it.

However, when I started a new project using WCF it got interesting, I could build already made WCF projects, but System.ServiceModel (and System.Runtime.Serialization for that matter) was nowhere to be found in the Add reference... dialog.

As I also do fiddle around with msbuild stuff I figured that I could work around this quite easily by firing up the project xml file (right-click the project, choose Unload project, right-click the unloaded project, choose Edit .csproj, Edit away..., then right-click project, Reload project)

and add the missing reference to the project by hand

<Reference Include="System.ServiceModel" />

Still, I thought it was kinda funny that the workaround was needed.


EDIT: This is not an issue anymore since Orcas CTP for RC1 has been released.