Registering proxy service problem

Topics: Web Client Software Factory
Jun 17, 2008 at 1:56 PM
Hello, we have upgrated out web from WCSF 1 to version 2.
Now we cant register our proxy services through IServiceCollection..::.Add  method and its overload Add(Type, Object)

here is the code:

public

class CasesModuleInitializer : ModuleInitializer

 


{
    ...
    

protected

virtual void AddModuleServices(IServiceCollection moduleServices)

 

{

        moduleServices.Add<Services.

ICRMCaseService>(WcfClient.ProxyFactory.CRMCaseServiceProxyInstance());

 

}

...
}

This code failed with an error : "Invalid type owner for DynamicMethod."
Stack trace:
 at System.Reflection.Emit.DynamicMethod.Init(String name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] signature, Type owner, Module m, Boolean skipVisibility, Boolean transparentMethod)
   at System.Reflection.Emit.DynamicMethod..ctor(String name, Type returnType, Type[] parameterTypes, Type owner)
   at Microsoft.Practices.CompositeWeb.ObjectBuilder.BuildPlan.DynamicMethodPlan.DynamicMethodPlanBuilderPolicy.CreatePlan(Type typeToBuild, String idToBuild)
   at Microsoft.Practices.CompositeWeb.ObjectBuilder.BuildPlan.BuildPlanStrategy.GetPlanFromContext(IBuilderContext context, Type typeToBuild, String idToBuild)
   at Microsoft.Practices.CompositeWeb.ObjectBuilder.BuildPlan.BuildPlanStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild)
   at Microsoft.Practices.ObjectBuilder.BuilderStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild)
   at Microsoft.Practices.CompositeWeb.ObjectBuilder.Strategies.SimplifiedSingletonStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild)
   at Microsoft.Practices.ObjectBuilder.BuilderStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild)
   at Microsoft.Practices.ObjectBuilder.TypeMappingStrategy.BuildUp(IBuilderContext context, Type t, Object existing, String id)
   at Microsoft.Practices.ObjectBuilder.BuilderStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild)
   at Microsoft.Practices.CompositeWeb.BuilderStrategies.ContainerAwareTypeMappingStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild)
   at Microsoft.Practices.CompositeWeb.ObjectBuilder.WCSFBuilderBase`1.DoBuildUp(IReadWriteLocator locator, Type typeToBuild, String idToBuild, Object existing, PolicyList[] transientPolicies)
   at Microsoft.Practices.CompositeWeb.ObjectBuilder.WCSFBuilderBase`1.BuildUp(IReadWriteLocator locator, Type typeToBuild, String idToBuild, Object existing, PolicyList[] transientPolicies)
   at Microsoft.Practices.CompositeWeb.Collections.ServiceCollection.BuildFirstTimeItem(Type typeToBuild, Type typeToRegisterAs, Object item)
   at Microsoft.Practices.CompositeWeb.Collections.ServiceCollection.Build(Type typeToBuild, Type typeToRegisterAs, Object serviceInstance)
   at Microsoft.Practices.CompositeWeb.Collections.ServiceCollection.Add(Type serviceType, Object serviceInstance)
   at Microsoft.Practices.CompositeWeb.Collections.ServiceCollection.Add[TService](TService serviceInstance)
   at Pokus.Cases.CasesModuleInitializer.AddModuleServices(IServiceCollection moduleServices) in xxx\CasesModuleInitializer.cs:line 34
   at Pokus.Cases.CasesModuleInitializer.Load(CompositionContainer container) in xxx\CasesModuleInitializer.cs:line 21
   at Microsoft.Practices.CompositeWeb.Services.ModuleLoaderService.Load(CompositionContainer rootContainer, IModuleInfo[] modulesInfo)

Before upgrade the same code worked fain...
Can u advice me where is the problem? I cant find anything about it.
Jun 17, 2008 at 9:05 PM

Hi,

Are you using the ProviderDependency attribute in your service? If yes, check this issue WCSF 2.0's ProviderDependency doesn't work to get IPageFlowProvider, if not, this may be something related and we will need you to give us more details about your service (if it is possible, post your service code).

Please, let me know if this helps.

Jonathan Cisneros

http://blogs.southworks.net/jcisneros/

Jun 17, 2008 at 11:28 PM
I used to meet this exception when a dependency of the service cannot be resolved by Object Builder.
All dependencies should be successfully registered before the service registration.

Chester
Jun 18, 2008 at 10:28 AM
Thank you guys for your answers.
Unfortunately the problem is still remind :(

For jonathan: We do not use ProviderDependency attribute for our service
Interesting thing is that ibefore upgrationg it worked fine, we use the same practice (the same app sever  + WCF in our thick client - SCSF)
For Chester: May I dont understand your note correctly, but I do not use ServiceDependency  injection jet. I just want to "register"/add my service to service collection to ne able to inject it later. If you mean web.config endpoints registration, so we have it

<

appSettings>

 

<

add key="communicationPlatform" value="WCF"/>

 

</

appSettings>

 

...
<!--

WCF Configuration -->

 

<

client>

 

<

endpoint name="CRMCaseService" address=http://localhost/xxxServices/CRMCaseService.svc binding="FenixBinding" bindingConfiguration="BindingConf" behaviorConfiguration="BehaviorConf" contract="xxx.Services.ICRMCaseService"/>

 



This link works fine: http://localhost/xxxServices/CRMCaseService.svc

Service definition looks like this:

[

ServiceContract]

 

 

public interface ICRMCaseService

 


    

[OperationContract]

 

 

     bool CloseCase(CRMCase entity);
     .....

 

}

public

class CRMCaseService : ICRMCaseService

 

{

 

public bool CloseCase(CRMCase entity)

 

{

 

    ..................
     return
true;

 

}


here is WCF proxy factory defenition:

static

ChannelFactory<xxx.Services.ICRMCaseService> factoryCRMCaseService = null;

 

//the method I call during registration of service in WCSF

public

static xxx.Services.ICRMCaseService CRMCaseServiceProxyInstance(CommunicationPlatform platform)

 

{

xxx.Services.

ICRMCaseService proxy = null;

 

 

try

 

{

 

switch (platform)

 

{

 

case CommunicationPlatform.Direct:

 

proxy =

new CRMCaseService() as ICRMCaseService;

 

 

break;

 

 

case CommunicationPlatform.WCF:

 

 

if (factoryCRMCaseService == null)

 

factoryCRMCaseService =

new ChannelFactory<TeamTrackers.Fenix.Services.ICRMCaseService>("CRMCaseService");

 

proxy = factoryCRMCaseService.CreateChannel();

 

break;

 

}

}

 

catch (Exception ex)

 

{

 

throw ex;

 

}

 

return proxy;

 

}