Could not load file or assembly 'EPiServer.Framework' - asp.net

Im getting this exception when configuring EPi CMS 5 to run under IIS7.5.
Exception Details: System.IO.FileNotFoundException: Could not load
file or assembly 'EPiServer.Framework' or one of its dependencies.
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 'EPiServer.Framework' 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:
[FileNotFoundException: Could not load file or assembly 'EPiServer.Framework' or one of its dependencies. Det går inte att
hitta filen.] System.RuntimeTypeHandle.GetTypeByName(String name,
Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly,
StackCrawlMarkHandle stackMark, Boolean loadTypeFromPartialName,
ObjectHandleOnStack type) +0
System.RuntimeTypeHandle.GetTypeByName(String name, Boolean
throwOnError, Boolean ignoreCase, Boolean reflectionOnly,
StackCrawlMark& stackMark, Boolean loadTypeFromPartialName) +95
System.RuntimeType.GetType(String typeName, Boolean throwOnError,
Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
+54 System.Type.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +65
System.Web.Compilation.BuildManager.GetType(String typeName, Boolean
throwOnError, Boolean ignoreCase) +69
System.Web.Configuration.ConfigUtil.GetType(String typeName, String
propertyName, ConfigurationElement configElement, XmlNode node,
Boolean checkAptcaBit, Boolean ignoreCase) +52
[ConfigurationErrorsException: Could not load file or assembly 'EPiServer.Framework' or one of its dependencies. Det går inte att
hitta filen.] System.Web.Configuration.ConfigUtil.GetType(String
typeName, String propertyName, ConfigurationElement configElement,
XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase) +360
System.Web.Configuration.ConfigUtil.GetType(String typeName, String
propertyName, ConfigurationElement configElement, Boolean
checkAptcaBit) +27
System.Web.Configuration.Common.ModulesEntry.SecureGetType(String
typeName, String propertyName, ConfigurationElement configElement) +44
System.Web.Configuration.Common.ModulesEntry..ctor(String name, String
typeName, String propertyName, ConfigurationElement configElement) +52
System.Web.HttpApplication.BuildIntegratedModuleCollection(List`1
moduleList) +200
System.Web.HttpApplication.GetModuleCollection(IntPtr appContext)
+1365 System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr
appContext, HttpContext context, MethodInfo[] handlers) +95
System.Web.HttpApplication.InitSpecial(HttpApplicationState state,
MethodInfo[] handlers, IntPtr appContext, HttpContext context) +194
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr
appContext, HttpContext context) +339
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr
appContext) +253
[HttpException (0x80004005): Could not load file or assembly 'EPiServer.Framework' or one of its dependencies. Det går inte att
hitta filen.] System.Web.HttpRuntime.FirstRequestInit(HttpContext
context) +9080108
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest
wr, HttpContext context) +256

Check the /Bin folder of your application and see if the EPiServer.Framework DLL is there. If it isn't you can set the DLL to "Copy Local" by right clicking on it in the References folder within Solution Explorer and selecting Properties, then set Copy Local to "true". Now when you build the solution, the DLL will be copied from it's reference location into the Bin folder. You may need to do this for all the EPiServer DLLs.
I've experienced this in the past and even when "Specific Version" is enabled there are still issue loading the correct DLLs. One way we solved it was to copy all the EPiServer DLLs into a Lib folder in our solution directory and add the references to those DLLs, keeping Specific Version and Copy Local set to true.

Related

Multiple Hangfire Recurring jobs can't be scheduled in DotNet 6

I have some hangfire jobs (10 jobs in total) in the asp dotNet core application. I keep adding until its ten. 4 of the run only once a week, and one runs every 5mins. Then others run at specific times during the day. I have recreated the hangfire jobs several times. it might run smoothly for, say, 45 mins and stop.
Before now, I have four jobs that have been running smoothly.
But now I am always getting this error on the ones running every 5 mins.
I tried this fix but didn't work
https://github.com/HangfireIO/Hangfire/pull/502#issuecomment-176744750
Modified
The app is deployed on Azure Appservice
System.InvalidOperationException: Recurring job can't be scheduled, see inner exception for details.
---> Hangfire.Common.JobLoadException: Could not load the job. See inner exception for the details.
---> System.TypeLoadException: Could not load type BackgroundJobs.ProcessAndSendNotifications' from assembly 'PortCall.Info, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
at System.Reflection.RuntimeAssembly.GetType(QCallAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type, ObjectHandleOnStack keepAlive, ObjectHandleOnStack assemblyLoadContext)
at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
at Hangfire.Common.TypeHelper.TypeResolver(Assembly assembly, String typeName, Boolean ignoreCase)
at System.TypeNameParser.ResolveType(Assembly assembly, String[] names, Func`4 typeResolver, Boolean throwOnError, Boolean ignoreCase, StackCrawlMark& stackMark)
at System.TypeNameParser.ConstructType(Func`2 assemblyResolver, Func`4 typeResolver, Boolean throwOnError, Boolean ignoreCase, StackCrawlMark& stackMark)
at System.TypeNameParser.GetType(String typeName, Func`2 assemblyResolver, Func`4 typeResolver, Boolean throwOnError, Boolean ignoreCase, StackCrawlMark& stackMark)
at System.Type.GetType(String typeName, Func`2 assemblyResolver, Func`4 typeResolver, Boolean throwOnError)
at Hangfire.Common.TypeHelper.DefaultTypeResolver(String typeName)
at Hangfire.Storage.InvocationData.DeserializeJob()
--- End of inner exception stack trace ---
at Hangfire.Storage.InvocationData.DeserializeJob()
at Hangfire.RecurringJobEntity..ctor(String recurringJobId, IDictionary`2 recurringJob, ITimeZoneResolver timeZoneResolver, DateTime now)
--- End of inner exception stack trace ---
at Hangfire.Server.RecurringJobScheduler.ScheduleRecurringJob(BackgroundProcessContext context, IStorageConnection connection, String recurringJobId, RecurringJobEntity recurringJob, DateTime now)
startup.cs
services.AddHangfire(h =>
{
h.UseSqlServerStorage(Configuration.GetConnectionString("Connection"));
});
services.AddHangfireServer();
.......
......
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
app.UseHangfireDashboard("/scheduler");
RecurringJob.AddOrUpdate<Jobs>("Mondays", UserReportJobs => Jobs.CruiseReport(), "0 6 * * MON");
....
....
....

IIS Breaks application after recycle

I recently have this strange issue with IIS. We have an ASP.NET website and recently it fails after an application pool recycle. When I stop the applicationpool, clear the "ASP.NET Temporary Files" and restart the applicationpool. It works again. When i manually recycle it, it breaks again. I can reproduce this every time. The big problem is that our web application recycles every night.
Can I in some way prevent the usage of these ASP.NET Temporary Files? Or how could i fix this issue.
[Edit]
this is a screenshot of the error:
Screenshot
[Edit 2:Full error page]
Server Error in 'WebSite' Application.
Could not load type from string value 'MyOwnClass'.
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 from string value 'MyOwnClass'.
Source Error:
Line 120: private static void InitalizeApplicationContext()
Line 121: {
Line 122: Spring.Context.Support.ContextRegistry.GetContext();
Line 123: }
Line 124:
Source File: path-to-website\Global.asax Line: 122
Stack Trace:
[TypeLoadException: Could not load type from string value 'MyOwnClass'.]
Spring.Core.TypeResolution.TypeResolver.Resolve(String typeName) +240
Spring.Core.TypeResolution.GenericTypeResolver.Resolve(String typeName) +530
Spring.Core.TypeResolution.CachedTypeResolver.Resolve(String typeName) +411
Spring.Core.TypeResolution.TypeResolutionUtils.ResolveType(String typeName) +85
Spring.Objects.Factory.Support.AbstractObjectDefinition.ResolveObjectType() +39
Spring.Objects.Factory.Support.AbstractObjectFactory.ResolveObjectType(RootObjectDefinition rod, String objectName) +74
[CannotLoadObjectTypeException: Cannot resolve type [MyOwnClass] for object with name 'AuthenticationUtil' defined in file [path-to-website\spring\Utils.xml] line 5]
Spring.Objects.Factory.Support.AbstractObjectFactory.ResolveObjectType(RootObjectDefinition rod, String objectName) +180
Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory.PredictObjectType(String objectName, RootObjectDefinition mod) +108
Spring.Objects.Factory.Support.DefaultListableObjectFactory.DoGetObjectNamesForType(Type type, Boolean includeNonSingletons, Boolean allowEagerInit) +879
Spring.Objects.Factory.Support.DefaultListableObjectFactory.GetObjectsOfType(Type type, Boolean includePrototypes, Boolean includeFactoryObjects) +99
Spring.Context.Support.AbstractApplicationContext.GetObjectsOfType(Type type) +51
Spring.Messaging.Core.MessageQueueMetadataCache.Initialize() +78
Spring.Messaging.Core.MessageQueueTemplate.CreateDefaultMetadataCache() +253
Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory.InvokeInitMethods(Object target, String name, IConfigurableObjectDefinition definition) +250
Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory.ConfigureObject(String name, RootObjectDefinition definition, IObjectWrapper wrapper) +740
Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory.InstantiateObject(String name, RootObjectDefinition definition, Object[] arguments, Boolean allowEagerCaching, Boolean suppressConfigure) +637
[ObjectCreationException: Error thrown by a dependency of object 'AddExamSessionToQueueCommand' defined in 'file [path-to-website\spring\Commands.xml] line 22' : Initialization of object failed : Cannot resolve type [MyOwnClass] for object with name 'AuthenticationUtil' defined in file [path-to-website\spring\Utils.xml] line 5
while resolving 'constructor argument with index 0' to 'MsmqExamSessionAccessCodeService' defined in 'file [path-to-website\spring\Services.xml] line 23'
while resolving 'MessageQueueTemplate' to 'ExamSessionAccessCodeMessageQueueTemplate' defined in 'file [path-to-website\spring\MsmqMessageQueueTemplates.xml] line 18']
Spring.Objects.Factory.Support.ObjectDefinitionValueResolver.ResolveReference(IObjectDefinition definition, String name, String argumentName, RuntimeObjectReference reference) +585
Spring.Objects.Factory.Support.ObjectDefinitionValueResolver.ResolvePropertyValue(String name, IObjectDefinition definition, String argumentName, Object argumentValue) +429
Spring.Objects.Factory.Support.ObjectDefinitionValueResolver.ResolveValueIfNecessary(String name, IObjectDefinition definition, String argumentName, Object argumentValue) +19
Spring.Objects.Factory.Support.ConstructorResolver.ResolveConstructorArguments(String objectName, RootObjectDefinition definition, ObjectWrapper wrapper, ConstructorArgumentValues cargs, ConstructorArgumentValues resolvedValues) +327
Spring.Objects.Factory.Support.ConstructorResolver.GetConstructorInstantiationInfo(String objectName, RootObjectDefinition rod, ConstructorInfo[] chosenCtors, Object[] explicitArgs) +263
Spring.Objects.Factory.Support.ConstructorResolver.AutowireConstructor(String objectName, RootObjectDefinition rod, ConstructorInfo[] chosenCtors, Object[] explicitArgs) +80
Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory.CreateObjectInstance(String objectName, RootObjectDefinition objectDefinition, Object[] arguments) +216
Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory.InstantiateObject(String name, RootObjectDefinition definition, Object[] arguments, Boolean allowEagerCaching, Boolean suppressConfigure) +863
Spring.Objects.Factory.Support.AbstractObjectFactory.CreateAndCacheSingletonInstance(String objectName, RootObjectDefinition objectDefinition, Object[] arguments) +379
Spring.Objects.Factory.Support.AbstractObjectFactory.GetObjectInternal(String name, Type requiredType, Object[] arguments, Boolean suppressConfigure) +1744
Spring.Objects.Factory.Support.DefaultListableObjectFactory.PreInstantiateSingletons() +722
Spring.Context.Support.AbstractApplicationContext.Refresh() +1009
Spring.Context.Support.XmlApplicationContext..ctor(XmlApplicationContextArgs args) +206
_dynamic_Spring.Context.Support.XmlApplicationContext..ctor(Object[] ) +320
Spring.Context.Support.RootContextInstantiator.InvokeContextConstructor(ConstructorInfo ctor) +169
Spring.Context.Support.ContextInstantiator.InstantiateContext() +55
Spring.Context.Support.ContextHandler.InstantiateContext(IApplicationContext parentContext, Object configContext, String contextName, Type contextType, Boolean caseSensitive, String[] resources) +174
Spring.Context.Support.ContextHandler.Create(Object parent, Object configContext, XmlNode section) +476
[ConfigurationErrorsException: Error creating context 'spring.root': Could not load type from string value 'MyOwnClass'.]
System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult) +278
System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject) +2095
System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject) +2023
System.Configuration.BaseConfigurationRecord.GetSection(String configKey) +79
System.Configuration.ConfigurationManager.GetSection(String sectionName) +91
Spring.Util.ConfigurationUtils.GetSection(String sectionName) +100
Spring.Context.Support.ContextRegistry.InitializeContextIfNeeded() +68
Spring.Context.Support.ContextRegistry.GetContext() +83
ASP.global_asax.InitalizeApplicationContext() in path-to-website\Global.asax:122
ASP.global_asax.Application_Start(Object sender, EventArgs e) in path-to-website\Global.asax:20
[HttpException (0x80004005): Error creating context 'spring.root': Could not load type from string value 'MyOwnClass'.]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +540
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +186
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +402
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +343
[HttpException (0x80004005): Error creating context 'spring.root': Could not load type from string value 'MyOwnClass'.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +539
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +125
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +731
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1590.0

asp.net URL Rewriting error

Could not load file or assembly 'UrlRewritingNet.UrlRewriter' or one of its dependencies. The system cannot find the file specified.
we installed the url rewriting
tried it on a website
tried it on a virtual directory
same error :/
any ideas?
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.IO.FileNotFoundException: Could not load file or assembly 'UrlRewritingNet.UrlRewriter' or one of its dependencies. The system cannot find the file specified.
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 'UrlRewritingNet.UrlRewriter' 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:
[FileNotFoundException: Could not load file or assembly 'UrlRewritingNet.UrlRewriter' or one of its dependencies. The system cannot find the file specified.]
System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type) +0
System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName) +153
System.Type.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +63
System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +124
System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase) +76
[ConfigurationErrorsException: Could not load file or assembly 'UrlRewritingNet.UrlRewriter' or one of its dependencies. The system cannot find the file specified.]
System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase) +12773840
System.Web.Configuration.Common.ModulesEntry.SecureGetType(String typeName, String propertyName, ConfigurationElement configElement) +69
System.Web.Configuration.Common.ModulesEntry..ctor(String name, String typeName, String propertyName, ConfigurationElement configElement) +66
System.Web.HttpApplication.BuildIntegratedModuleCollection(List`1 moduleList) +300
System.Web.HttpApplication.GetModuleCollection(IntPtr appContext) +1262
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +133
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 'UrlRewritingNet.UrlRewriter' or one of its dependencies. The system cannot find the file specified.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12966756
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12806561
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18408
Just copy the UrlRewritingNet.UrlRewriter.dll and paste it in both parent and child's bin folder .. it might be not present in the child bin folder
Kindly change you application pool setting of sub web site.
to different app. pool framework.

Getting error while migrating asp.net project from VS2005/framework v2.0 to VS2010/framework v3.0

Server Error in Application.
Could not load file or assembly 'GetFieldsProxy.XmlSerializers' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
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 'GetFieldsProxy.XmlSerializers' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
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 'GetFieldsProxy.XmlSerializers' 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 'GetFieldsProxy.XmlSerializers' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.]
System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0
System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +43
System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +127
System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +142
System.Reflection.Assembly.Load(String assemblyString) +28
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +46
[ConfigurationErrorsException: Could not load file or assembly 'GetFieldsProxy.XmlSerializers' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +613
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +203
System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +105
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +178
System.Web.Compilation.WebDirectoryBatchCompiler..ctor(VirtualDirectory vdir) +163
System.Web.Compilation.BuildManager.BatchCompileWebDirectoryInternal(VirtualDirectory vdir, Boolean ignoreErrors) +53
System.Web.Compilation.BuildManager.BatchCompileWebDirectory(VirtualDirectory vdir, VirtualPath virtualDir, Boolean ignoreErrors) +175
System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) +86
System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +261
System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +101
System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean noAssert) +126
System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp, Boolean noAssert) +62
System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) +33
System.Web.UI.PageHandlerFactory.System.Web.IHttpHandlerFactory2.GetHandler(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) +40
System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig) +160
System.Web.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +93
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
Version Information: Microsoft .NET Framework Version:2.0.50727.5472; ASP.NET Version:2.0.50727.5456
One of your projects still targets 2.0 and it references another one which targets 3.0 or higher. Just make sure ALL your projects are upgraded and target the new version of the framework (3.0 from what you write).
Most probably this is the web site main project that still targets .net 2.0.

Sharepoint woes: Could not load file or assembly - BadImageFormatException

I've been working on a project that's been a rather seat-of-the-pants experience.
We have MOSS 2007 and Silverlight 3 installed.
We're trying to make use of some new 3rd party software, Visual Fusion(http://www.idvsolutions.com/products_overview.aspx).
While working through the tutorial I ran into a bit of an issue. All I really have to go on is the guidance package and sample stuff they provided so it's still a little fuzzy.
Basically when I debug the project in Visual Studio 2008, instead of loading the default.aspx page, I get this on my browser instead:
Server Error in '/' Application.
--------------------------------------------------------------------------------
Could not load file or assembly 'Microsoft.SharePoint.Search, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. An attempt was made to load a program with an incorrect format.
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 'Microsoft.SharePoint.Search, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. An attempt was made to load a program with an incorrect format.
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:
[BadImageFormatException: Could not load file or assembly 'Microsoft.SharePoint.Search, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0
System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +43
System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +127
System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +142
System.Reflection.Assembly.Load(String assemblyString) +28
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +46
[ConfigurationErrorsException: Could not load file or assembly 'Microsoft.SharePoint.Search, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +613
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +203
System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +105
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +178
System.Web.Compilation.WebDirectoryBatchCompiler..ctor(VirtualDirectory vdir) +163
System.Web.Compilation.BuildManager.BatchCompileWebDirectoryInternal(VirtualDirectory vdir, Boolean ignoreErrors) +53
System.Web.Compilation.BuildManager.BatchCompileWebDirectory(VirtualDirectory vdir, VirtualPath virtualDir, Boolean ignoreErrors) +175
System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) +86
System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +261
System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +101
System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean noAssert) +126
System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp, Boolean noAssert) +62
System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) +33
System.Web.UI.PageHandlerFactory.System.Web.IHttpHandlerFactory2.GetHandler(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) +40
System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig) +160
System.Web.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +93
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
I've spent the last few hours poking around for answers and it seems to be related to the fact that I'm running this all on a 64-bit machine, but all the references to workarounds I found were rather vague.
What other information do I need to provide to help pinpoint the issue? I'm a bit overwhelmed at the moment.
if you're running on a 64bit machine, then ipso-facto the sharepoint installation is 64bit. Most of the sharepoint assemblies are x64 only, so this error is a result of your product trying to load the 64bit assembly into a 32bit process (running 32bit clr.)
Without knowing the product that's trying to load the sharepoint assembly, it's hard to tell what's going on. If this is custom code, set the project build target architecture to x64 and rebuild.
-Oisin

Resources