AppFabric: Cache host cannot load provider assembly for read-through and write-behind - caching

I want to try out the new read-through/write-behind feature of AppFabric 1.1. I implemented a provider that references some other own assemblies, according to http://msdn.microsoft.com/en-us/library/hh361698%28v=azure.10%29.aspx. All are signed and compiled for AnyCPU. I put the provider and all referenced assemblies in the GAC (see http://msdn.microsoft.com/en-us/library/hh361703(v=azure.10).aspx). Then I stopped the cache cluster and created a new cache with the read-through and write-behind options passing the full name of my provider assembly (that I got from gacutil -l).
New-Cache ReadThroughWriteBehindCache -ReadThroughEnabled true -WriteBehindEnabled true
-WriteBehindInterval 60 -ProviderType "CachingDemo.Provider, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=236fd28d53a6f1ad" -ProviderSettings #{"connectionString"="Data Source=.;Initial
Catalog=Demo;Persist Security Info=True;User
ID=sa;Password=password;MultipleActiveResultSets=True";"logFilePath"="C:\Logs\CacheProvider"}
When starting the cache cluster again I got a timeout and following error message in the event log:
AppFabric Caching service crashed with exception Microsoft.ApplicationServer.Caching.DataCacheException:
ErrorCode<ERRCMS0007>:SubStatus<ES0001>:Provider "CachingDemo.Provider, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=236fd28d53a6f1ad" instantiation failed: The given assembly name
or codebase was invalid. (Exception from HRESULT: 0x80131047) ---> System.IO.FileLoadException:
The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
What could possibly be wrong? I triple-checked the assembly name. The name I passed when creating the cache is exactly the same as the one I get from gacutil -l. The assembly is AnyCPU what should work in any case. Since the assembly is not even loaded errors inside the assembly can be ruled-out.

The reason was that the provider type information was not correctly passed when creating the cache. I assumed that AppFabric would find the provider itself (by reflection). But we have to add the provider type in the ProviderType argument. Additionaly between the type and the assembly information only a comma is allowed (not a comma with a space for example):
New-Cache ReadThroughWriteBehindCache -ReadThroughEnabled true -WriteBehindEnabled true
-WriteBehindInterval 60 -ProviderType CachingDemo.Provider.Provider,CachingDemo.Provider,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=236fd28d53a6f1ad"
-ProviderSettings #{"connectionString"="Data Source=.;
Initial Catalog=Demo;Persist Security Info=True;
User ID=sa;Password=password;MultipleActiveResultSets=True";
"logFilePath"="C:\Logs\CacheProvider"}

Related

Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.0 with difference mvc version

My MVC 4 project(use System.Web.Mvc.DLL version 4) was working,but now suddenly I get an error(without anything).That error occurs in my controller which call EF code first code from data layer
This is the line causing the error in MVC 4 Project:
var cultures = db.Cultures.Select(c => c.Code).ToArray();//call from data layer
In my mvc project I have deleted the data layer and added it again it again and then I set that DLL copy local to true but the error was not fixed.
My MVC project use System.Web.Mvc, Version=4.0.0.0 and copy local is true And Data layer use System.Web.Mvc, Version=3.0.0.0 and copy local is true
I looked error inner exception it give that error
Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Did you check your Web.config file? You should have a dependentAssembly defined for System.Web.Mvc that specifies its version.

Could not load file or assembly 'System.Web.Http.WebHost...' or one of its dependencies. The module was expected to contain an assembly manifest

I have an MVC application that my customers deploy locally. It has worked for years.
I have a customer trying to load it in this environment:
SERVER: Windows Small Business Server 2011 Standard
IIS: 7.5
.NET: 3.5.1 & 4.5
They are deploying as a subdomain, but receive this error:
Server Error in '/' Application.
Could not load file or assembly 'System.Web.Http.WebHost, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The
module was expected to contain an assembly manifest.
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.BadImageFormatException: Could not load file or assembly
'System.Web.Http.WebHost, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
or one of its dependencies. The module was expected to contain an assembly manifest.
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.
Assembly Load Trace: The following information can be helpful to determine why the assembly
'System.Web.Http.WebHost, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
could not be loaded.
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value
[HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
Stack Trace:
[BadImageFormatException: Could not load file or assembly 'System.Web.Http.WebHost,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its
dependencies. The module was expected to contain an assembly manifest.]
site.MvcApplication.Application_Start() in f:\Users\{path}\site\Global.asax.cs:912
[HttpException (0x80004005): Could not load file or assembly 'System.Web.Http.WebHost,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its
dependencies. The module was expected to contain an assembly manifest.]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext
context, HttpApplication app) +12864673
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext,
HttpContext context, MethodInfo[] handlers) +175
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers,
IntPtr appContext, HttpContext context) +304
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext,
HttpContext context) +404
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +475
[HttpException (0x80004005): Could not load file or assembly 'System.Web.Http.WebHost,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its
dependencies. The module was expected to contain an assembly manifest.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12881540
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr,
HttpContext context) +12722601
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.17929
I have tried
copying the indicated dll from a working directory to no avail.
checking the application pool information
comparing settings between working sites and this one
Many Google searches
Fresh install of the application and IIS
Nothing we try seems to work. Ideas?
I deleted the bin folder, and rebuilt the application. Then I went through and made certain that the needed dlls were copied to local on publish and it works now.

How can I enable Telerik Openaccess ORM load external assemblies?

I'm new at Telerik OpenAccess ORM and I use other assemblies like CRISII (in house built for templates). I use these with other ORM's successfully like SubSonic but can't with Telerik. Here is my error:
Error 73 Unable to load assembly 'WritingChallenge, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' : Could not load file or assembly 'CRISII, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b589e2deb0b5c884' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
ExceptionString:
System.SystemException: Unable to load assembly 'WritingChallenge, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' : Could not load file or assembly 'CRISII, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b589e2deb0b5c884' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515) ---> 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.RuntimeModule.GetTypes()
at System.Reflection.Assembly.GetTypes()
at Telerik.OpenAccess.Metadata.MetadataAttributesReader.PrepareMetaModelTypes(Assembly assembly)
--- End of inner exception stack trace ---
at Telerik.OpenAccess.Metadata.MetadataAttributesReader.PrepareMetaModelTypes(Assembly assembly)
at Telerik.OpenAccess.Metadata.MetadataAttributesReader.ReadMetaModel(Assembly assembly)
at Telerik.OpenAccess.Metadata.AttributesMetadataSource.<>c__DisplayClass1.<FromAssembly>b__0()
at Telerik.OpenAccess.Metadata.AttributesMetadataSource.CreateModel()
at Telerik.OpenAccess.Metadata.MetadataSource.GetModelCore(MetadataContainer old)
at Telerik.OpenAccess.Sdk.Enhancer.Enhancer.CrossDomainRunImpl(AssemblyLoader assemblyLoader)
at Telerik.OpenAccess.Sdk.Enhancer.EnhancerBase.CrossDomainRun() C:\SVNProjects\WritingChallenge\WritingChallenge\obj\Debug\WritingChallenge.dll WritingChallenge
A possible cause for this issue is the Attributes mapping, you are using for your domain model. You could try switching to XML mapping and using it as your mapping approach.

CLR Can't find a type, even though it's in the same assembly

I'm troubleshooting a WCF problem in our application, and turned on WCF tracing with the WCF Service Configuration Editor in VS 2010, which added the following sharedListener to the web.config:
<sharedListeners>
<add initializeData="D:\Logs\CRCCustomerService\Web_tracelog.svclog"
type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelTraceListener" traceOutputOptions="Timestamp">
<filter type="" />
</add>
</sharedListeners>
Now, when I take steps to reproduce my error, I'm getting an exception thrown from the System.Diagostics library saying that it can't find XmlWriterTraceListener:
Stack Trace:
System.TypeInitializationException: The type initializer for 'System.ServiceModel.DiagnosticUtility' threw an exception. ---> System.Configuration.ConfigurationErrorsException: Couldn't find type for class System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
at System.Diagnostics.TraceUtils.GetRuntimeObject(String className, Type baseType, String initializeData)
at System.Diagnostics.TypedElement.BaseGetRuntimeObject()
at System.Diagnostics.ListenerElement.GetRuntimeObject()
at System.Diagnostics.ListenerElement.GetRuntimeObject()
at System.Diagnostics.ListenerElementsCollection.GetRuntimeObject()
at System.Diagnostics.TraceSource.Initialize()
at System.Diagnostics.TraceSource.get_Listeners()
And it goes on for several more lines, but this establishes the context.
My question is, since, according to ObjectBrowser and Reflector, XmlWriterTraceListener is a member class of the same assembly that System.Diagnostics is, how can it NOT not be able to find it?
And secondly, since every single line in the exception stack comes from system code, how on earth do I begin to debug the root cause here?
Are you using .NET 4.0?
If not, you have to beware the service config utility. It will hard code the version of the listener to 4.0 and you'll need to manually change your web.config

Unable to serialize the session state, which is related to System.Data.Linq. EntitySet

Recently I am playing with the Windows Server 2008,
and would like to make some configuration for my web application.
I have changed the Session State for my application to "State Server" so it can make use of more work process (Now it is set to 4).
Afterwards I have got this error when I attempt to login to the application.
Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted. The same restriction applies if similar serialization is done by the custom session state store in 'Custom' mode.
I suspect it is related to the EntitySet I have declared because I see this in the Stack Trace when the error occur:
[SerializationException: Type
'System.Data.Linq.EntityRef`1[[CtcSystem.Domain.Entities.Account.Account,
CtcSystem.Domain, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null]]' in Assembly 'System.Data.Linq, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as
serializable.]
I have used [Serializable] tag on my classes,
so is there any way I have to do to make the EntitySet serializable so that the application can run under State Server?
Thanks
Best way is to implement the ISerializable interface on a partial class...

Resources