This is my situation: I am using Visual Studio 2015 with .NET Framework 4.6.1 on a Win 10 64-bit machine for building a WCF Service.
In my solution I have several different project types, mainly plain C# Class Library
(class libraries), some C++
-dll references, and of course the WCF Service Library
itself.
Before I continue I would like to state that this is my first date with WCF ever...
This SO question is addressing a similar problem, Where is the startup method of a WCF Service?, but since I'm dealing with a WCF Service Library
a couple of years later when the original question was asked, and the fact that the original question is not using the same project type, I believe that (?) the answer there is not adaptable for my problem. Not when just debugging at least?
In my solution, I have set my WCF Service Library
-project as StartUp project. When hitting the F5-key (for Start), this is what I get:
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.Assembly.GetTypes()
at Microsoft.Tools.SvcHost.ServiceHostHelper.LoadServiceAssembly(String svcAssemblyPath)
Ok, normally, in a plain C# Console Application
, I would have set up a try-catch-block in the Main()
-method in order to examine my problem. But my WCF Service Library
-project doesn't seem to have such.
My question: How can I find out what the LoaderException
property is?
EDIT 1: I tried @user497745's answer (both proposals) and the first one helped me:
-
- I fired up Visual Studio > Debug > Windows > Exception Settings
- and provided the following settings:
- When starting my error prone WCF project I still got the very same message as before
- When trying another option that @user497745 suggested, disabling Visual Studio > Debug > Options > Debugging > General > Just My Code, I got closer to my Exception:
-
- I tried the second proposal with diagnostics tracing by adding sections in my App.config file for the
WCF Class Library
. - This is part of my
App.config
:<system.serviceModel> <diagnostics> <messageLogging logEntireMessage="true" logMalformedMessages="false" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="false" maxMessagesToLog="3000" maxSizeOfMessageToLog="2000"/> </diagnostics> <behaviors> <serviceBehaviors> <behavior name="HemsamaritenServiceBehavior"> <serviceMetadata httpGetEnabled="true"/> <serviceDebug includeExceptionDetailInFaults="true"/> </behavior> </serviceBehaviors> </behaviors> <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> <services> <!-- This section is optional with the new configuration model introduced in .NET Framework 4. --> <service name="WCFServiceLibrary.HemsamaritenDuplexService" behaviorConfiguration="HemsamaritenServiceBehavior"> <host> <baseAddresses> <add baseAddress="http://localhost:8000/Hemsamariten/service"/> </baseAddresses> </host> <!-- this endpoint is exposed at the base address provided by host: http://localhost:8000/Hemsamariten/service --> <endpoint address="" binding="wsDualHttpBinding" contract="WCFServiceLibrary.Interfaces.IHemsamaritenDuplexService" /> <!-- the mex endpoint is exposed at http://localhost:8000/Hemsamariten/service/mex --> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> </service> </services> </system.serviceModel> <system.diagnostics> <sources> <source name="System.ServiceModel" switchValue="All" propagateActivity="true"> <listeners> <add name="xml" /> </listeners> </source> <source name="System.ServiceModel.MessageLogging" switchValue="All"> <listeners> <add name="xml" /> </listeners> </source> </sources> <sharedListeners> <add initializeData="C:\Users\haunsTM\Desktop\WinService\debuglog.svclog" type="System.Diagnostics.XmlWriterTraceListener" name="xml" /> </sharedListeners> <trace autoflush="true" /> </system.diagnostics>
- I started my application running Visual Studio 2015 as Administrator
Unfortunately my output directory,Unfortunately, somehow, the Build checkbox in the Configuration Manager had been unchecked for my executable. When checking it, I got a long log message!C:\Users\haunsTM\Desktop\WinService\debuglog.svclog
, was empty after the run.
- I tried the second proposal with diagnostics tracing by adding sections in my App.config file for the