Adding WebGet gives error..

Using VS2008 Beta2
-

Code Snippet

Server Error in '/' Application.

Could not load type 'System.ServiceModel.Administration.IWmiInstanceProvider' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

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.TypeLoadException: Could not load type 'System.ServiceModel.Administration.IWmiInstanceProvider' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

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:

[TypeLoadException: Could not load type 'System.ServiceModel.Administration.IWmiInstanceProvider' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.]

System.ModuleHandle.ResolveType(Int32 typeToken, RuntimeTypeHandle* typeInstArgs, Int32 typeInstCount, RuntimeTypeHandle* methodInstArgs, Int32 methodInstCount) +0

System.ModuleHandle.ResolveTypeHandle(Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) +214

System.Reflection.Module.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) +211

System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, Module decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, RuntimeMethodHandle& ctor, Boolean& ctorHasParameters, Boolean& isVarArg) +122

System.Reflection.CustomAttribute.GetCustomAttributes(Module decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes) +419

System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeMethodInfo method, RuntimeType caType, Boolean inherit) +126

System.Reflection.RuntimeMethodInfo.GetCustomAttributes(Type attributeType, Boolean inherit) +63

System.ServiceModel.Description.ServiceReflector.GetCustomAttributes(ICustomAttributeProvider attrProvider, Type attrType, Boolean inherit) +40



[InvalidOperationException: An error occurred while loading attribute 'OperationBehaviorAttribute' on method 'Tasks' in type 'ICollaborateService'. Please see InnerException for more details.]

System.ServiceModel.Description.ServiceReflector.GetCustomAttributes(ICustomAttributeProvider attrProvider, Type attrType, Boolean inherit) +516

System.ServiceModel.Description.TypeLoader.CreateOperationDescriptions(ContractDescription contractDescription, ContractReflectionInfo reflectionInfo, Type contractToGetMethodsFrom, ContractDescription declaringContract, MessageDirection direction) +134

System.ServiceModel.Description.TypeLoader.CreateContractDescription(ServiceContractAttribute contractAttr, Type contractType, Type serviceType, ContractReflectionInfo& reflectionInfo, Object serviceImplementation) +896

System.ServiceModel.Description.TypeLoader.LoadContractDescriptionHelper(Type contractType, Type serviceType, Object serviceImplementation) +174

System.ServiceModel.Description.ContractDescription.GetContract(Type contractType, Type serviceType) +59

System.ServiceModel.ServiceHost.CreateDescription(IDictionary`2& implementedContracts) +314

System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection baseAddresses) +144

System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses) +236

System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(Type serviceType, Uri[] baseAddresses) +28

System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses) +323

System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath) +699

System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +31

System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +445



[ServiceActivationException: The service '/CollaborateService.svc' cannot be activated due to an exception during compilation. The exception message is: An error occurred while loading attribute 'OperationBehaviorAttribute' on method 'Tasks' in type 'ICollaborateService'. Please see InnerException for more details..]

System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +962

System.ServiceModel.ServiceHostingEnvironment.EnsureServiceAvailableFast(String relativeVirtualPath) +419

System.ServiceModel.Activation.HostedHttpRequestAsyncResult.HandleRequest() +264

System.ServiceModel.Activation.HostedHttpRequestAsyncResult.BeginRequest() +760

System.ServiceModel.Activation.HostedHttpModuleRequestAsyncResult.BeginRequest() +178

System.ServiceModel.Activation.HttpModule.StartBeginProcessRequest(Object sender, EventArgs e, AsyncCallback cb, Object extraData) +70

System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender, EventArgs e) +195

System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +92

System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64




Version Information:
Microsoft .NET Framework Version:2.0.50727.1378; ASP.NET Version:2.0.50727.1378


[12531 byte] By [simnova] at [2008-1-8]
# 1

Erm... if you would have some more detailed information about your service? Smile

Which endpoints? Which binding configs etc.? Config, code snippets.

ChristianWeyer at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 2
The following are the steps I am taking which produce the error.

(I'm quite certain that I'm missing more that would properly implement WebGet, however I think that there is something wrong with my enviornment to cause this particular error and am not sure what the best method of resolving it would be)

  1. Create new project in VS2008
    1. Choose WCF Service Application Project Type
  2. Add A Reference to System.ServiceModel.Web
  3. Open the IService.cs file
  4. Add "using System.ServiceModel.Web" and add attributre "[WebGet]" under the [OperationContract] to the two sample functions.
  5. Set Service.svc as the start page.
  6. Start Debugging, get the aforementioned errror..

Sample Code: (from IService.cs)

...
using System.ServiceModel.Web;

// A WCF service consists of a contract (defined below as IService).
[ServiceContract]
public interface IService
{

[OperationContract]
[WebGet]
string GetData(int intParam);

[OperationContract]
[WebGet]
CompositeType GetDataUsingDataContract(CompositeType composite);

// TODO: Add your service operations here
}
...


simnova at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 3

Hm, I cannot reproduce this error - I did the exact same steps.

Do you have a clean install of Orcas on a clean machine?

ChristianWeyer at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 4
I'm not certain as to how to get to a clean install w/out recoring my system.

I've repaired OrcasB2 on my machine, no luck, will try uninstalling and reinstalling next..

simnova at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 5
I've done the following:

  • Uninstalled everything Orcas Beta 2 related.
  • Removed the following two branches from the registry:
    • HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0
    • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0
  • Reinstalled Orcas Beta 2
  • Created new WCF Web Service Web Site as outlined in earlier post, received the same error.
I'm not sure what else to do now short of recoring my machine from scratch, any suggestions would be helpful.

simnova at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 6
What is ICollaborateService? Is this your service? Because you said you just added the two attributes to the already existing service...

ChristianWeyer at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 7
That was from a project that I am working on, essentially the same error with that project or the simplier method I described. Here's the error from the sample project:

Code Snippet

Server Error in '/WCFService1' Application.

Could not load type 'System.ServiceModel.Administration.IWmiInstanceProvider' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

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.TypeLoadException: Could not load type 'System.ServiceModel.Administration.IWmiInstanceProvider' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

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:

[TypeLoadException: Could not load type 'System.ServiceModel.Administration.IWmiInstanceProvider' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.]
System.ModuleHandle.ResolveType(Int32 typeToken, RuntimeTypeHandle* typeInstArgs, Int32 typeInstCount, RuntimeTypeHandle* methodInstArgs, Int32 methodInstCount) +0
System.ModuleHandle.ResolveTypeHandle(Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) +214
System.Reflection.Module.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) +211
System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, Module decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, RuntimeMethodHandle& ctor, Boolean& ctorHasParameters, Boolean& isVarArg) +122
System.Reflection.CustomAttribute.GetCustomAttributes(Module decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes) +419
System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeMethodInfo method, RuntimeType caType, Boolean inherit) +126
System.Reflection.RuntimeMethodInfo.GetCustomAttributes(Type attributeType, Boolean inherit) +63
System.ServiceModel.Description.ServiceReflector.GetCustomAttributes(ICustomAttributeProvider attrProvider, Type attrType, Boolean inherit) +36

[InvalidOperationException: An error occurred while loading attribute 'OperationBehaviorAttribute' on method 'GetData' in type 'IService'. Please see InnerException for more details.]
System.ServiceModel.Description.ServiceReflector.GetCustomAttributes(ICustomAttributeProvider attrProvider, Type attrType, Boolean inherit) +512
System.ServiceModel.Description.TypeLoader.CreateOperationDescriptions(ContractDescription contractDescription, ContractReflectionInfo reflectionInfo, Type contractToGetMethodsFrom, ContractDescription declaringContract, MessageDirection direction) +134
System.ServiceModel.Description.TypeLoader.CreateContractDescription(ServiceContractAttribute contractAttr, Type contractType, Type serviceType, ContractReflectionInfo& reflectionInfo, Object serviceImplementation) +1031
System.ServiceModel.Description.TypeLoader.LoadContractDescriptionHelper(Type contractType, Type serviceType, Object serviceImplementation) +204
System.ServiceModel.Description.ContractDescription.GetContract(Type contractType, Type serviceType) +53
System.ServiceModel.ServiceHost.CreateDescription(IDictionary`2& implementedContracts) +470
System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection baseAddresses) +145
System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses) +288
System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(Type serviceType, Uri[] baseAddresses) +29
System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses) +320
System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath) +690
System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +32
System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +445

[ServiceActivationException: The service '/WCFService1/Service.svc' cannot be activated due to an exception during compilation. The exception message is: An error occurred while loading attribute 'OperationBehaviorAttribute' on method 'GetData' in type 'IService'. Please see InnerException for more details..]
System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +952
System.ServiceModel.ServiceHostingEnvironment.EnsureServiceAvailableFast(String relativeVirtualPath) +416
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.HandleRequest() +258
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.BeginRequest() +742
System.ServiceModel.Activation.HostedHttpModuleRequestAsyncResult.BeginRequest() +176
System.ServiceModel.Activation.HttpModule.StartBeginProcessRequest(Object sender, EventArgs e, AsyncCallback cb, Object extraData) +68
System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender, EventArgs e) +194
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +92
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64



Version Information: Microsoft .NET Framework Version:2.0.50727.1378; ASP.NET Version:2.0.50727.1378



simnova at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 8

This is typically because the System.ServiceModel.Web.dll has been gac'd in but the updated System.ServiceModel.dll has not been gac'd in.

Can you try uninstalling .NET Framework 3.0 (and forcibly removing System.ServiceModel.dll from the GAC) and then reinstall Orcas beta2?


Thanks

Vish

T.R.Vishwanath-MSFT at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 9
Still not having much luck.
  1. Uninstalled Orcas Beta2 (and anything related including .NET Framework 3.5)
  2. Could not uninstall .NET Framework 3.0 (Running Vista, it's built in)
  3. Did a force uninstall ( "gacutil /uf System.ServiceModel") to remove, confirmed no nonger presnet by using gacutil /l System.Service model
  4. Rebooted
  5. Reinstalled Orcas Beta2
  6. Started new project.... Same Error...
  7. Used Lutz Roeder's .NET Reflector, noted no IWmiInstanceProvider, must have wrong version..
Any ideas where to go from here would be appreciated..

Output from gacutil after performing process above:
C:\Program Files\Microsoft SDKs\Windows\v6.0>gacutil /l System.ServiceModel
Microsoft (R) .NET Global Assembly Cache Utility. Version 2.0.50727.312
Copyright (c) Microsoft Corporation. All rights reserved.

The Global Assembly Cache contains the following assemblies:
System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c56
1934e089, processorArchitecture=MSIL

Number of items = 1


FYI It appears as though someone in Korea is having the same issue:

http://www.sysnet.pe.kr/Default.aspx?mode=3&sub=0&pageno=0&detail=1&wid=687

simnova at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 10
The version of the System.ServiceModel.dll I have on my machine is : 3.0.4506.25

I'm not sure if this is correct.

I've seen references about a version 3.0.4506.30
http://www.alexthissen.nl/blogs/main/default.aspx?p=2

I'm wondering if there could be an issue with the installer not dropping the correct version..

I've posted the same issue in Microsoft Connect to two different areas as I'm not sure which matches the issue best.

- Visual Studio Feedback : https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=295019

- WCF Feedback:
https://connect.microsoft.com/wcf/feedback/ViewFeedback.aspx?FeedbackID=295018

simnova at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...

Visual Studio Orcas

Site Classified