C++ support in WSE 2.0 SP2
WSE 2.0 SP2 adds some support for adding WSE to C++
projects, which had been missing since the initial release
last May.
At last, the WSE Configuration Editor, the one that comes up
when you right-click in the Solution Explorer and then
select WSE 2.0 Settings allows you to enable and disable WSE
for C++ project and lets you create policies.
Before SP2, nothing would happen when you clicked on the
item in the context menu. Unfortunately, other IDE
integration, such as automatic generation of WSE proxies in
a WSE enabled project is still not happening and probably
will never happen in WSE 2 because wsewsdl2.exe does not
support generation of C++ code. If you take a look with
Reflector, you'll find that for some reason, the tool does
not emit the proxy code via CodeDOM, hence it would be
really difficult for the WSE team to generate C++ proxy
classes.
A general shortcoming of the IDE integration of the
configuration tool, that's not specific the C++ projects are
the relative references generated for the policy files. When
you enable policy for a C++ an application project (not a
web service), the tool will add
<policy>
<cache name="../policyCache.config" />
</policy>
to the application's configuration file. Unfortunately, the
relative reference would only valid during development -- if
C++ projects behaved like C# projects in the first place.
When you deploy the application you most likely will not
have the policyCache.config file one directory higher than
the application and its config file. To complicate matters a
little further, C++ application projects behave differentely
than C# of VB.NET projects in Visual Studio. C++ projects
don't even copy the app.config file to the output directory.
The best solution is to delete the relative path information
from the path to the policyCache.config file.
<policy>
<cache name="policyCache.config" />
</policy>
and then add a post build event to rename app.config and
copy it, together with the policyCache file to the output
directory:
copy $(ProjectDir)app.config
$(OutDir)\$(TargetFileName).config /Y
copy "$(ProjectDir)policyCache.config" $(OutDir)\
/Y
Changing the path and letting the post build event do the
work for you also helps when you build an installer. Simply
mark the policyCache.config file as "Content", add "Content
File" to the installer project and you're ready to go.
Finally, when you build and ASP.NET Web service in C++ you
have to make sure that the policyCache.config file is
deployed to the web server.