I have been working on a VB.net web application for some time now, and I accidentally switched the "Application Type" setting from a Class Library to a Windows Form Application. I tried to build, this failed, but when I switched back, the program would no longer execute, displaying the error:
Unable to start program 'C:\Users\User\...\bin\Project.dll'
'C:\Users\User\...\bin\Project.dll' is not a valid Win32 application.
Prior to this the application would build fine.
Furthermore, in the properties page for the project, the "Web" section displays the error:
An error occurred trying to load the page.
Value does not fall within the expected range.
The build output offers no clues as to the unexpected behavior, it builds fine, it just won't run. The code is also fully functional.
I have tried restarting multiple times, deleting the /bin directory and allowing it to rebuild from scratch (then restoring the old contents when this failed), setting the startup project, changing the target CPU and debug/release mode. I have tried both ReSharper build, and Visual Studio build.
I also tried making a build configuration that targeted 'C:\Users\User...\bin\Project.vshost.exe', but this would execute then close immediately.
I have no option to set a "Startup Object" in the application page of the project settings, but this has never been an issue. I have never needed to target an EXE to run my application before. If I try other application types, it states "Sub Main was not found in project".
I cannot recreate the project due to it's size so would love it if anyone could offer some insight, next time I will be mindful not to play around with the IDE settings.
======= UPDATED =======
So I fixed the "not running issue" by changing the WebProjectProperties to:
<UseIIS>True</UseIIS>
<UseCustomServer>False</UseCustomServer>
<servers defaultServer="">
But now when I run the program, the following error is displayed:
Could not load file or assembly
'Microsoft.VisualStudio.QualityTools.UnitTestFramework (2)' or one of
its dependencies. The located assembly's manifest definition does not
match the assembly reference. (Exception from HRESULT: 0x80131040)
System.IO.FileLoadException: Could not load file or assembly
'Microsoft.VisualStudio.QualityTools.UnitTestFramework (2)' or one of
its dependencies. The located assembly's manifest definition does not
match the assembly reference. (Exception from HRESULT: 0x80131040)
Stack trace and details:
=== Pre-bind state information ===
LOG: DisplayName = Microsoft.VisualStudio.QualityTools.UnitTestFramework (2)
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: Microsoft.VisualStudio.QualityTools.UnitTestFramework (2) | Domain ID: 2
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/Users/User/Source/Repos/Findem/IfitConsulting/
LOG: Initial PrivatePath = C:\Users\User\Source\Repos\Findem\IfitConsulting\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\User\Source\Repos\Findem\IfitConsulting\web.config
LOG: Using host configuration file: C:\Users\User\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/0ef61219/b7128029/Microsoft.VisualStudio.QualityTools.UnitTestFramework (2).DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/0ef61219/b7128029/Microsoft.VisualStudio.QualityTools.UnitTestFramework (2)/Microsoft.VisualStudio.QualityTools.UnitTestFramework (2).DLL.
LOG: Attempting download of new URL file:///C:/Users/User/Source/Repos/Findem/IfitConsulting/bin/Microsoft.VisualStudio.QualityTools.UnitTestFramework (2).DLL.
WRN: Comparing the assembly name resulted in the mismatch: NAME
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
Stack trace
[FileLoadException: Could not load file or assembly 'Microsoft.VisualStudio.QualityTools.UnitTestFramework (2)' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +36
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +152
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +77
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +21
System.Reflection.Assembly.Load(String assemblyString) +28
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +38
[ConfigurationErrorsException: Could not load file or assembly 'Microsoft.VisualStudio.QualityTools.UnitTestFramework (2)' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +738
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +217
System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +170
System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +92
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +290
System.Web.Compilation.BuildManager.ExecutePreAppStart() +157
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +531
[HttpException (0x80004005): Could not load file or assembly 'Microsoft.VisualStudio.QualityTools.UnitTestFramework (2)' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9947380
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +261
Ok so finally figured out how to fix it, hopefully this can help some other poor soul who ends up in the same situation!
The first step is to edit your project.vbproj file and change:
<WebProjectProperties>
<UseIIS>False</UseIIS>
<UseCustomServer>True</UseCustomServer>
<servers defaultServer="SelfHostServer">
...
</servers>
</WebProjectProperties>
To
<WebProjectProperties>
<UseIIS>True</UseIIS>
<UseCustomServer>False</UseCustomServer>
<servers defaultServer="">
...
</servers>
</WebProjectProperties>
Then, you want to go to your /bin directory and delete the following files (Project is your projects name):
Project.dll
Project.dll.CodeAnalysisLog.xml
Project.dll.config
Project.dll.CodeAnalysisLog
Project.pdb
Project.xml
And re-build and it all works fine!
Related
I am working on an eCommerce site using Asp.Net 5 and MVC6 following Onion Architecture (OA) so that we have loose coupling between the layers. I also want to decouple Startup code in its own assembly rather than having it in the MVC project.
In beta7 It was very easy to move the Startup.cs to a class library (Bootstrapper) as explained here. One interesting fact using the mentioned approach is that I didn't have to reference the Bootstrapper assembly from the MVC project. At runtime, hosting under IISExpress, through assembly scanning it was able to find the Bootstrapper assembly mentioned in the Microsoft.AspNet.Hosting.ini file. This was possible by specifying the location in the global.json
{
"projects": [ "Source/Projects","Source/Bootstrapper" ],
"sdk": {
"architecture": "x64",
"runtime": "clr",
"version": "1.0.0-beta7"
}
}
The Bootstrapper project will have reference to all other projects like Infrastructure, Services etc in order to hook up Dependency Injection.
The reason for not referencing the Bootstrapper project in MVC project, following Onion Architecture rules, is to avoid having access to Infrastructure code directly from MVC project. So this was all working fine until I upgraded to Beta8 this morning.
As the hosting model is changed from IIS to Kestrel, I had to refactor the global.json and project.json files as below
global.json
{
"projects": [ "Source/Projects","Source/Bootstrapper" ],
"sdk": {
"architecture": "x64",
"runtime": "clr",
"version": "1.0.0-beta8"
}
}
project.json
{
"dependencies": {
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-beta8",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-beta8",
"....",
"....",
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel"
}
}
After making the above changes, I started getting the following error regardless whether I run it using dnx command or directly via Visual Studio
Internal Server Error System.InvalidOperationException A
type named 'StartupDevelopment' or 'Startup' could not be found in
assembly 'EcommerceMvcApp'. at
Microsoft.AspNet.Hosting.Startup.StartupLoader.FindStartupType(String
startupAssemblyName, IList diagnosticMessages) at
Microsoft.AspNet.Hosting.Internal.HostingEngine.EnsureStartup() at
Microsoft.AspNet.Hosting.Internal.HostingEngine.EnsureApplicationServices()
at Microsoft.AspNet.Hosting.Internal.HostingEngine.BuildApplication()
Turned out that I have to specify the config file or inline arguments to the web command as explained here. After following the suggestion, I tried running the application and this time I started getting the error below
System.IO.FileNotFoundException Could not load file or assembly
'Bootstrapper' or one of its dependencies. The system cannot find the
file specified. at
System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String
codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint,
StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean
throwOnFileNotFound, Boolean forIntrospection, Boolean
suppressSecurityChecks) at
System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String
codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint,
StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean
throwOnFileNotFound, Boolean forIntrospection, Boolean
suppressSecurityChecks) at
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName
assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly,
StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean
throwOnFileNotFound, Boolean forIntrospection, Boolean
suppressSecurityChecks) at
System.Reflection.Assembly.Load(AssemblyName assemblyRef) at
Microsoft.AspNet.Hosting.Startup.StartupLoader.FindStartupType(String
startupAssemblyName, IList diagnosticMessages) at
Microsoft.AspNet.Hosting.Internal.HostingEngine.EnsureStartup() at
Microsoft.AspNet.Hosting.Internal.HostingEngine.EnsureApplicationServices()
at Microsoft.AspNet.Hosting.Internal.HostingEngine.BuildApplication()
The solution requires that I add a reference to the Bootstrapper project in the MVC project and it works. However, it defeats the purpose of having a separate Bootstrapper assembly in the first place.
The question is, why it is unable to find the Bootstrapper assembly like it used to do in Beta7, using the sources specified under "projects" in global.json or is the new hosting model ignoring the global.json? Is there a way to specify the location of the Startup assembly?
Update 1
Just want to highlight that in Beta7 it also works using "dnx command" for both Microsoft.AspNet.Server.WebListener and Microsoft.AspNet.Server.Kestrel.
"commands": {
"kestrel": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel --server.urls http://localhost:5004 --config wwwroot/Microsoft.AspNet.Hosting.ini",
"web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5004 --config wwwroot/Microsoft.AspNet.Hosting.ini"
}
However, the dnx command (using Microsoft.AspNet.Hosting.json file) fails for both servers in Beta8. If someone is wondering that it's something to do with IIS Helios component in Beta7, it's not the case. I am baffled as why the assembly lookup stopped working in Beta8
Update 2
Here is the stack trace that I get when I try to run in Beta8 using IISExpress. Looks like it's trying to find the assembly in the dnx bin folder.
System.IO.FileNotFoundException: Could not load file or assembly
'Bootstrapper' or one of its dependencies. The system cannot find the
file specified. File name: 'Bootstrapper' at
System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String
codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint,
StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean
throwOnFileNotFound, Boolean forIntrospection, Boolean
suppressSecurityChecks) at
System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String
codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint,
StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean
throwOnFileNotFound, Boolean forIntrospection, Boolean
suppressSecurityChecks) at
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName
assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly,
StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean
throwOnFileNotFound, Boolean forIntrospection, Boolean
suppressSecurityChecks) at
System.Reflection.Assembly.Load(AssemblyName assemblyRef) at
Microsoft.AspNet.Hosting.Startup.StartupLoader.FindStartupType(String
startupAssemblyName, IList`1 diagnosticMessages) at
Microsoft.AspNet.Hosting.Internal.HostingEngine.EnsureStartup() at
Microsoft.AspNet.Hosting.Internal.HostingEngine.EnsureApplicationServices()
at Microsoft.AspNet.Hosting.Internal.HostingEngine.BuildApplication()
=== Pre-bind state information === LOG: DisplayName = Bootstrapper (Partial) WRN: Partial binding information was supplied for an
assembly: WRN: Assembly Name: Bootstrapper | Domain ID: 1 WRN: A
partial bind occurs when only part of the assembly display name is
provided. WRN: This might result in the binder loading an incorrect
assembly. WRN: It is recommended to provide a fully specified textual
identity for the assembly, WRN: that consists of the simple name,
version, culture, and public key token. WRN: See whitepaper
http://go.microsoft.com/fwlink/?LinkId=109270 for more information and
common solutions to this issue. LOG: Appbase =
file:///C:/Users/sshassan/.dnx/runtimes/dnx-clr-win-x86.1.0.0-beta8/bin/
LOG: Initial PrivatePath = NULL Calling assembly : (Unknown).
=== LOG: This bind starts in default load context. LOG: No application configuration file found. LOG: Using host configuration file: LOG:
Using machine configuration file from
C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private,
custom, partial, or location-based assembly bind). LOG: Attempting
download of new URL
file:///C:/Users/sshassan/.dnx/runtimes/dnx-clr-win-x86.1.0.0-beta8/bin/Bootstrapper.DLL.
LOG: Attempting download of new URL
file:///C:/Users/sshassan/.dnx/runtimes/dnx-clr-win-x86.1.0.0-beta8/bin/Bootstrapper/Bootstrapper.DLL.
LOG: Attempting download of new URL
file:///C:/Users/sshassan/.dnx/runtimes/dnx-clr-win-x86.1.0.0-beta8/bin/Bootstrapper.EXE.
LOG: Attempting download of new URL
file:///C:/Users/sshassan/.dnx/runtimes/dnx-clr-win-x86.1.0.0-beta8/bin/Bootstrapper/Bootstrapper.EXE.
Perhaps, if I run dnu publish and host it under IIS it will work, but that means that I would have to publish it every time I make the change
I was stuck in a similar problem. It looks like we do not want to make references from UI layer to Infraestructure layer (we are very stricts), not even for making the dependency resolution.
Maybe it is possible by using late binding (I just heard talked about it), but I think that you should read this article. It basically says that a Composition Root isn't reusable, and there should be one per application (i.e., one for UI.Web, another for UI.Console, and so on).
That responds also my question about what having the DI resolution in UI.Web, but need another UI, let's say Console (answer: it's preferable to make anoter DI resolution in Console, and it'll have it's own resolution dependences related to how a Console Application actually works).
I hope having give you a good point to clarify this issue.
The hosting config file format changed from INI to Json. Try this:
{
"Hosting:Application": "Bootstrapper",
}
Also see this issue.
My MVC4 Web Api application is working fine when it is build in Any Cpu mode.In this mode it is creating 32 bit dll. However when I build the application in x64 mode then while executing it is giving following error:
Server Error in '/' Application.
--------------------------------------------------------------------------------
Could not load file or assembly 'CoreService' 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 'CoreService' 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.
Assembly Load Trace: The following information can be helpful to determine why the assembly 'CoreService' could not be loaded.
=== Pre-bind state information ===
LOG: User = xxx
LOG: DisplayName = CoreService
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: CoreService | Domain ID: 3
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///D:/StartFromScratch/src/CoreService/
LOG: Initial PrivatePath = D:\StartFromScratch\src\CoreService\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: D:\StartFromScratch\src\CoreService\web.config
LOG: Using host configuration file: C:\Users\310138409\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/a4e7fe2c/87c2ced5/CoreService.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/a4e7fe2c/87c2ced5/CoreService/CoreService.DLL.
LOG: Attempting download of new URL file:///D:/StartFromScratch/src/CoreService/bin/CoreService.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.
Stack Trace:
[BadImageFormatException: Could not load file or assembly 'CoreService' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +34
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +152
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +77
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +16
System.Reflection.Assembly.Load(String assemblyString) +28
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +38
[ConfigurationErrorsException: Could not load file or assembly 'CoreService' 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) +752
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +218
System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +170
System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +91
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath) +258
System.Web.Compilation.BuildManager.ExecutePreAppStart() +135
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +516
[HttpException (0x80004005): Could not load file or assembly 'CoreService' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9874840
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18055
I am not getting any concrete solution for the same. Moreover we cannot continue in 32 bit mode as It is making call to 64 bit unmanaged code. Thanks in advance.
Actually problem is because of IISExpress. It is 32bit of IISExpress is running whenever we are executing from VS2012 IDE so it is giving incorrect format error. So once I installed the IISexpress 8.0 and done the registry entry to make sure that IISExpress 64 bit get executed from VS2012; my problem got resolved.
You should properly configure your solution configurations for x64 build. Right click on your solution in VS, select Configuration Manager select x64 under Active solution platforms drop down list and check whether all of your projects has built with x64 platform.
We use NServiceBus.Host.exe to host our service and the assembly for our endpoint is located in the same folder with NServiceBus.Host.exe. Under the main folder we have a subfolder containing assemblies that are needed for our processes handling the messages. The problem we have is that when NServiceBus.Host.exe loads it finds the assemblies from the subfolder but can't load them and crashes with an error:
Unhandled Exception: Magnum.StateMachine.StateMachineException: Exception occurred in Topshelf.Internal.ServiceController1[
[NServiceBus.Hosting.Windows.WindowsHost, NServiceBus.Host, Version=3.0.0.0, Culture=neutral, PublicKeyToken=9fc386479f8a226c]] during state Initial while handling OnStart ---> Microsoft.Practices.ServiceLocation.ActivationException: Activation error occured while trying to get instance of type WindowsHost, key "MyPoint.BusMessageEndPoint, MyPoint, Version=4.3.0.0, Culture=neutral, PublicKeyToken=null" ---> System.IO.FileNotFoundException: Could not load file or assembly 'MyAssembly, Version=4.3.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.Load(String assemblyString)
at System.Linq.Enumerable.WhereSelectArrayIterator2.MoveNext()
at System.Collections.Generic.List1..ctor(IEnumerable1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source)
at NServiceBus.Hosting.GenericHost..ctor(IConfigureThisEndpoint specifier, String[] args, IEnumerable1 defaultProfiles,String endpointName, IEnumerable1 scannableAssembliesFullName) in c:\NServiceBus-NServiceBus-3.3.5-0\src\hosting\NServiceBus.Hosting\GenericHost.cs:line 145 at NServiceBus.Hosting.Windows.WindowsHost..ctor(Type endpointType, String[] args, String endpointName, Boolean runOtherInstallers, Boolean runInfrastructureInstallers, IEnumerable1 scannableAssembliesFullName) in c:\NServiceBus-NServiceBus-3.3.5-0\src\hosting\NServiceBus.Hosting.Windows\WindowsHost.cs:line 31
at NServiceBus.Hosting.Windows.HostServiceLocator.DoGetInstance(Type serviceType, String key) in c:\NServiceBus-NServiceBus-3.3.5-0\src\hosting\NServiceBus.Hosting.Windows\HostServiceLocator.cs:line 41
at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key) in :line 0
It seems that the host finds the assemblies in some way but can't load them. I haven't found any way to tell the host not to look inside the subfolder. Everything works fine if I move the assemblies from the subfolder to the mainfolder (in the same folder where the NServiceBus.Host.exe is) but that makes our structure very untidy and this subfolder way worked just fine with NServiceBus 2.6 - now after upgrading to 3.3.5 we have a problem.
Is there some way to block subfolders from the hosts load - or if the host finds the assemblies in the subfolder why can't it load them? That would solve our problem too.
Many thanks if someone can help me with this.
I'll add my comments to the answers here, if I can clarify our case a bit. Thanks for the answers!
The assemblies in the subfolder are not needed to be loaded by NSericeBus.Host.exe - they are loaded from our message endpoint assembly (which is loaded by NServiceBus.Host) by using MEF.
In NServiceBus 2.6 the assemblies in the subfolder either were not loaded by NServiceBus.Host or it could handle them and now is not able to do so. The load crashes before I can affect what it loads. In debug the crash happens before the Configure.With() happens so I can't tell NServiceBus to dismiss the subfolder.
If you enable custom initialization via the IWantCustomInitialization interface, the .With() method has options to provide a specific directory or a list of assemblies or types.
You can't have those necessary assemblies in a subfolder. I wasn't aware that this worked in 2.6 but if so it was probably unintended. I do know that somewhere in there the method used to load assemblies was changed so that we could use Configure.With() in all instances and not have to decide between .With() and .WithWeb when self-hosting. Perhaps this is a side-effect of that change.
In any case, why does it matter if the main deployment directory is "untidy"? I would think this would just complicate deployment scenarios to try to make it look prettier and certainly wouldn't add any business value.
I have a multi-tier Azure application I've been working on. It uses web and worker roles behind an MVC front end, as well as Azure SQL and Table storage. It has been working well for a while, both in the emulator and the cloud.
I've just started adding some Service Bus functionality to it, adding the Service Bus package from NuGet, and now I find that although everything still compiles, I am getting the following runtime error:
Server Error in '/' Application.
Could not load file or assembly 'Microsoft.WindowsAzure.Configuration' or one of its dependencies. Strong name signature could not be verified. The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045)
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.FileLoadException: Could not load file or assembly 'Microsoft.WindowsAzure.Configuration' or one of its dependencies. Strong name signature could not be verified. The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045)
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 'Microsoft.WindowsAzure.Configuration' could not be loaded.
=== Pre-bind state information ===
LOG: User = JCFXLAPTOP\User
LOG: DisplayName = Microsoft.WindowsAzure.Configuration
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: Microsoft.WindowsAzure.Configuration | Domain ID: 2
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///D:/Work/CLIENTS/PageEngine/Solutions/PageEngine/Web.PageEngine/
LOG: Initial PrivatePath = D:\Work\CLIENTS\PageEngine\Solutions\PageEngine\Web.PageEngine\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: D:\Work\CLIENTS\PageEngine\Solutions\PageEngine\Web.PageEngine\web.config
LOG: Using host configuration file: C:\Program Files\IIS Express\config\templates\PersonalWebServer\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/root/4904ccbc/14659c77/Microsoft.WindowsAzure.Configuration.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/root/4904ccbc/14659c77/Microsoft.WindowsAzure.Configuration/Microsoft.WindowsAzure.Configuration.DLL.
LOG: Attempting download of new URL file:///D:/Work/CLIENTS/PageEngine/Solutions/PageEngine/Web.PageEngine/bin/Microsoft.WindowsAzure.Configuration.DLL.
LOG: Using application configuration file: D:\Work\CLIENTS\PageEngine\Solutions\PageEngine\Web.PageEngine\web.config
LOG: Using host configuration file: C:\Program Files\IIS Express\config\templates\PersonalWebServer\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Microsoft.WindowsAzure.Configuration, Version=1.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
ERR: Failed to complete setup of assembly (hr = 0x80131045). Probing terminated.
Stack Trace:
[FileLoadException: Could not load file or assembly 'Microsoft.WindowsAzure.Configuration' or one of its dependencies. Strong name signature could not be verified. The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045)]
[FileLoadException: Could not load file or assembly 'Microsoft.WindowsAzure.Configuration, Version=1.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. Strong name signature could not be verified. The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045)]
System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +210
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +242
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +17
System.Reflection.Assembly.Load(String assemblyString) +35
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +122
[ConfigurationErrorsException: Could not load file or assembly 'Microsoft.WindowsAzure.Configuration, Version=1.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. Strong name signature could not be verified. The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045)]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +12731430
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +503
System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +142
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +334
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath) +203
System.Web.Compilation.BuildManager.ExecutePreAppStart() +152
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1151
[HttpException (0x80004005): Could not load file or assembly 'Microsoft.WindowsAzure.Configuration, Version=1.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. Strong name signature could not be verified. The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045)]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12847312
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12675965
I noticed that the ServiceBus NuGet package references a newer version of the Microsoft.WindowsAzure.Configuration dll (1.7.0.2), and wondered if that might be the cause. I've tried overriding this and changing all references to either 1.7.0.0 or 1.7.0.2 - neither change helped. I've also tried removing all Azure references from the solution and re-adding references by installing NuGet packages and referencing the latest SDK. This hasn't helped either.
I should add that at all times the Microsoft.WindowsAzure.Configuration dll has been in the bin folder of the MVC application, and that it has always had CopyLocal set to true.
I note that the Azure Configuration NuGet package was updated very recently (Friday 27th July), and I wonder if that might have something to do with it.
Does anybody know what the issue could be?
EDIT
Just to confirm that removing the service bus nuget package fixes the problem. Reinstating it causes the problem to recur. I don't know if this matters but the Microsoft.WindowsAzure.Configuration dll added as part of the NuGet package seems to have an inconsistent version number. While the path suggests the version should be 1.7.0.2:
D:\Work\CLIENTS\PageEngine\Solutions\PageEngine\packages\Microsoft.WindowsAzure.ConfigurationManager.1.7.0.2\lib\net35-full\Microsoft.WindowsAzure.Configuration.dll
... the version number in the properties inspector is still 1.7.0.0
This was an issue with the Microsoft.WindowsAzure.Configuration assembly, version 1.7.0.2
Temporarily fixed by rolling back to either 1.7.0.1 or 1.7.0.0 and then permanently fixed in 1.7.0.3
Had same problem. I reverted Microsoft.WindowsAzure.ConfigurationManager back to NuGet version 1.7.0.1. Now it is working OK.
I need help with configuring Reporting Services.
I have the ReportServer and Report Manager running successfully under a virtual website and under their own virtual directories (Reports and ReportServer) on port 80.
I then tried to set up another virtual website running on port 1001 with the same virtual directory names I am able to access the Report Server fine under port 1001 but when I try and access the Report Manager I get a Server error. I have used Reporting Services Configuration to create the virtual directories for ReportServer and Report Manager and all looks fine within it. The error I get when accessing Report Manager is as below:
Server Error in '/Reports' Application.
--------------------------------------------------------------------------------
Could not load file or assembly 'ReportingServicesWebServer' or one of its dependencies. The system cannot find the file specified.
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 'ReportingServicesWebServer' 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 'ReportingServicesWebServer' 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 'ReportingServicesWebServer' or one of its dependencies. The system cannot find the file specified.]
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 'ReportingServicesWebServer' or one of its dependencies. The system cannot find the file specified.]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +613
System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +57
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +178
System.Web.Compilation.BuildProvidersCompiler..ctor(VirtualPath configPath, Boolean supportLocalization, String outputAssemblyName) +54
System.Web.Compilation.ApplicationBuildProvider.GetGlobalAsaxBuildResult(Boolean isPrecompiledApp) +227
System.Web.Compilation.BuildManager.CompileGlobalAsax() +52
System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +337
[HttpException (0x80004005): Could not load file or assembly 'ReportingServicesWebServer' or one of its dependencies. The system cannot find the file specified.]
System.Web.Compilation.BuildManager.ReportTopLevelCompilationException() +58
System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +512
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters) +729
[HttpException (0x80004005): Could not load file or assembly 'ReportingServicesWebServer' or one of its dependencies. The system cannot find the file specified.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +8890735
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +85
System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +259
Does anyone know why this could be happening? Thanks a lot.
see this http://technet.microsoft.com/en-us/sqlserver/dd391734.aspx