I have a rather expensive library which I've inherited from another project. This assembly is using interception via Unity and requires an elaborate Web.config for design time configuration. I am attempting to use this assembly from within a MSMQ WCF Service, and I'm receiving errors when the code inside the assembly attempts to open DB connections that are hosted by Enterprise Library.
Resolution of the dependency failed, type =
"ServicesImplementation.EntityMaster.IEntityRepository", name =
"(none)". Exception occurred while: while resolving. Exception is:
InvalidOperationException - The current type,
ServicesImplementation.EntityMaster.IEntityRepository, is an interface
and cannot be constructed. Are you missing a type mapping?
My question, is it required that I assume all configuration responsibilities from my WCF Service, or is this configuration encapsulated within the referenced assembly.
You must include all configuration in your .config file. It is defalult source for application to get it config data. Also notice, that if you host in IIS, you should use web.config, if not(Windows Service or app) - use app.config. It is possible to extract section configuration to another file and reference it from your main config.
For example:
Assembly1 contains service definition and host logic.
Assembly2 actualy hosts Assembly1 service.
In this case all service configuration must reside in Assembly2 *.config file.
I have a client that references two assemblies : a WCF service and DLL containing dataContracts.
At the same time, the client consumes the WSDL of the WCF Service. The problem is that the service reference does not proxy DataContracts (just the service methods). Instead it puts the DataContracts into 'Properties/DataSources/' folder. Each has an extension 'datasource' When opened i get an XML that looks like this :
<?XML version="1.0" encoding="utf-8"?>
<!--
This file is automatically generated by Visual Studio .Net. It is
used to store generic object data source configuration information.
Renaming the file extension or editing the content of this file may
cause the file to be unrecognizable by the program.
-->
<GenericObjectDataSource DisplayName="DataContractClass" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
<TypeInfo>MySolution.ContractClasses, MySolution, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo>
</GenericObjectDataSource>
Thanks in advance for your replies.
Ok I understand now, it seems to be a cool feature of WCF : instead of proxying the datacontracts it reuses (maps to) the dll containing the DataContracts.
UPDATE : I've tried it on a bigger solution and it works like a charm, I just have one if DEBUG instead of plenty (namespaces):
#if DEBUG
static Service client = new Service();
#else
static ServiceClient client = new ServiceClient();
#endif
I have a problem trying to initialise my IOC container in a WCF application. The application is non HTTP based using WAS.
When I start the application I get this error message...
Kernel was null, did you forgot to call DefaultServiceHostFactory.RegisterContainer
I have seen other answers to this solution which say to do the following...
Add a Factory definition to the ServiceHost definition e.g.
Factory="Castle.Facilities.WcfIntegration.DefaultServiceHostFactory, Castle.Facilities.WcfIntegration"
Create a class in th App_Code folder with a static method called AppInitialize(). This method should then automatically be called and you can use it to register your container.
I have done this but my AppInitialize method is not called and I am still getting the error above.
Thanks.
I will go through what i've done so far step by step as below:
created empty solution
added a website WCFService
deleted the Service and IService from the website
added a WCF service library project to the solution
added end points to the web.config
did the same in app.config
added a reference to the service library in the web application
ctrl + F5
9
I get the following error:
Server Error in '/WFLedger'
Application. The type
'Services.WFLedger.WF_Ledger',
provided as the Service attribute
value in the ServiceHost directive, or
provided in the configuration element
system.serviceModel/serviceHostingEnvironment/serviceActivations
could not be found. Description: An
unhandled exception occurred during
the execution of the current web
request. Please review the stack trace
for more information about the error
and where it originated in the code.
Exception Details:
System.InvalidOperationException: The
type
'Services.WFLedger.WF_API_Ledger',
provided as the Service attribute
value in the ServiceHost directive, or
provided in the configuration element
system.serviceModel/serviceHostingEnvironment/serviceActivations
could not be found.
Source Error:
An unhandled exception was generated
during the execution of the current
web request. Information regarding the
origin and location of the exception
can be identified using the exception
stack trace below.
Stack Trace:
[InvalidOperationException: The type
'Services.WFLedger.WF_Ledger',
provided as the Service attribute
value in the ServiceHost directive, or
provided in the configuration element
system.serviceModel/serviceHostingEnvironment/serviceActivations
could not be found.]
System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String
constructorString, Uri[]
baseAddresses) +654
System.ServiceModel.HostingManager.CreateService(String
normalizedVirtualPath) +1439
System.ServiceModel.HostingManager.ActivateService(String
normalizedVirtualPath) +45
System.ServiceModel.HostingManager.EnsureServiceAvailable(String
normalizedVirtualPath) +647
[ServiceActivationException: The
service '/WFLedger/WF_Ledger.svc'
cannot be activated due to an
exception during compilation. The
exception message is: The type
'Services.WFAPILedger.WF_API_Ledger',
provided as the Service attribute
value in the ServiceHost directive, or
provided in the configuration element
system.serviceModel/serviceHostingEnvironment/serviceActivations
could not be found..]
System.Runtime.AsyncResult.End(IAsyncResult
result) +437
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult
result) +188
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication
context, String
routeServiceVirtualPath, Boolean
flowContext, Boolean ensureWFService)
+230 System.ServiceModel.Activation.HttpModule.ProcessRequest(Object
sender, EventArgs e) +360
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+213 System.Web.HttpApplication.ExecuteStep(IExecutionStep
step, Boolean& completedSynchronously)
+76
this is really driving me crazy!!!
why am i getting this error?
if you need more information please let me know so that i provide them to you
thanks a million in advance
Look at the WF_Ledger.svc file in your web site project. It should only consist of one line. There'll be Service attribute containing "Services.WFAPILedger.WF_API_Ledger". WCF is looking for the "Services.WFAPILedger.WF_API_Ledger" class but not finding it. The namespace and class name need to either exist in the web site project or be a reference as you're trying to set up. You'll need to edit that Service attribute to match the service implementation class in the WCF service library project.
Please check if the .svc file is provided and is of the following form.
<% #ServiceHost Language=C# Debug="true" Service="MyService" CodeBehind="~/App_Code/Service.cs" %>
Its all one line and the file should contain nothing else.
Try to add new default service then check newly added works fine.
If yes, check web.config endpoint contract name provided,
and in .svc file check code behind mentioned correctly.
In .svc file Service parameter should include namespace followed by class name i.e. it should be in the format mynamespace.myservice
Build the WCF project and try again. This error may occur because of the absence of a DLL in bin folder.
For me building and trying again resolved it.
Even make sure that, In your .svc file directive, The "service" attribute's value is fully qualified class name, i.e example: if your namespace is like "ns1.ns2.ns3.ClassName" (where ns1, ns2,ns3 are namespaces).
This error can be generated by renaming a class name in the *.svc.cs file without renaming it in the *.svc markup.
Two ways to resolve this problem:
Rename the class name to the original name.
Rename the service reference in the markup (right click in *.svc file, then click "View Markup"*).
Your markup code looks like this:
<%# ServiceHost Language="C#" Debug="true" Service="WCFSample.MyClass"CodeBehind="MyClass.svc.cs" %>
*Note: I had this problem in VS2017, don't know if that option is in VS2010.
check the function name and parameter in Iservice class where you calling the function and checkout your Service class also where function is define..
I'm following this guide here:
http://www.lostechies.com/blogs/jimmy_bogard/archive/2008/09/16/integrating-structuremap-and-nhibernate-with-wcf.aspx
And has now come to the end of it where i need to add :
<%# ServiceHost Language="C#" Debug="true" Service="Wcf.ComboService" Factory="Wcf.DIServiceHostFactory" %>
to my svcfile,
the problem is that i dont have an svcfile and according to this post you must add a reference from a Web-application to get it:
Adding .svc file missing
Is there really no way to do this? or maybe make this code work without the svc-file?
An .svc file is just a text file with a different extension, so you can always add it as a text file, no matter what sort of Visual Studio solution you use.
It's not compiled, but rather sits alongside the WCF binaries, instructing IIS on how to create service instances. If configured correctly, IIS interprets the .svc file and spins up the service from the binaries.
However, if you don't want to host your service in IIS, you don't need an .svc file. You can just use the ServiceHostFactory to manually spin up the service:
var factory = new Wcf.DIServiceHostFactory();
var host = factory.CreateServiceHost(typeof(Wcf.ComboService), baseAddresses);
host.Open();
This is called self-hosting.