Solved

Could not load file or assembly

Posted on 2008-06-11
8
1,183 Views
Last Modified: 2012-08-13
Hi

I've been following a simple example to run web server from a command line using ASP.NET.

http://aspalliance.com/220_Running_ASPNET_within_a_CommandLine_exe_Outside_of_IIS.all#Page1

It seems I don't have the necessary files available to run the application. Here is the stack trace. How do I find out what files are missing?

Thanks
Andrew
System.IO.FileNotFoundException was unhandled

  Message="Could not load file or assembly 'MyHost, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified."

  Source="mscorlib"

  FileName="MyHost, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"

  FusionLog="=== Pre-bind state information ===

LOG: User = MINDY2\\aj

LOG: DisplayName = MyHost, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null\n (Fully-specified)

LOG: Appbase = file:///C:/Documents and Settings/aj/My Documents/Host/

LOG: Initial PrivatePath = C:\\Documents and Settings\\aj\\My Documents\\Host\\bin

Calling assembly : (Unknown).

===

LOG: This bind starts in default load context.

LOG: Using application configuration file: C:\\Documents and Settings\\aj\\My Documents\\Host\\web.config

LOG: Using machine configuration file from c:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\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/v2.0.50727/Temporary ASP.NET Files/foo/c94177b4/4af4c657/MyHost.DLL.

LOG: Attempting download of new URL file:///c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/foo/c94177b4/4af4c657/MyHost/MyHost.DLL.

LOG: Attempting download of new URL file:///C:/Documents and Settings/aj/My Documents/Host/bin/MyHost.DLL.

LOG: Attempting download of new URL file:///C:/Documents and Settings/aj/My Documents/Host/bin/MyHost/MyHost.DLL.

LOG: Attempting download of new URL file:///c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/foo/c94177b4/4af4c657/MyHost.EXE.

LOG: Attempting download of new URL file:///c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/foo/c94177b4/4af4c657/MyHost/MyHost.EXE.

LOG: Attempting download of new URL file:///C:/Documents and Settings/aj/My Documents/Host/bin/MyHost.EXE.

LOG: Attempting download of new URL file:///C:/Documents and Settings/aj/My Documents/Host/bin/MyHost/MyHost.EXE.

"

  StackTrace:

       at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)

       at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)

       at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)

       at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)

       at System.Reflection.Assembly.Load(String assemblyString)

       at System.UnitySerializationHolder.GetRealObject(StreamingContext context)

       at System.Web.Hosting.HostingEnvironment.CreateInstance(Type type)

       at System.Web.Hosting.ApplicationManager.CreateInstanceInNewWorkerAppDomain(Type type, String appId, VirtualPath virtualPath, String physicalPath)

       at System.Web.Hosting.ApplicationHost.CreateApplicationHost(Type hostType, String virtualDir, String physicalDir)

       at AspHostTest.MyAspHost.Main(String[] args)

  InnerException: 

Open in new window

0
Comment
Question by:j055
  • 4
  • 2
8 Comments
 

Author Comment

by:j055
ID: 21758344
Made the stack trace and error log more readable
0
 
LVL 14

Expert Comment

by:Daniel Junges
ID: 21758429
0
 

Author Comment

by:j055
ID: 21758468
Thanks for that. I have followed that example too already. It looks like my problem is more to do with the .NET Framework assembly binding, i.e. it's looking for assmblies that don't exists. I can't work out why it's looking for the assemblies. It doesn't make a lot of sense to me.

I wonder if this line is a clue:

LOG: Initial PrivatePath = C:\\Documents and Settings\\aj\\My Documents\\Host\\bin
Calling assembly : (Unknown).

That folder doesn't exist but why is it looking for it?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 14

Expert Comment

by:Daniel Junges
ID: 21758563
place all compiled files into C:\\Documents and Settings\\aj\\My Documents\\Host\\bin

and the aspx files into C:\\Documents and Settings\\aj\\My Documents\\Host\

that is the needed folder structure for asp.net
0
 

Author Comment

by:j055
ID: 21758942
THat's how everything is. I've double checked. I didn't have a dll in the bin folder because the Default.aspx test page only contained static html. I changed it and recompiled so I have a dll in the bin folder. I still get the same errors.

Why is the application trying to load a file called MyHost.DLL? That doesn't exist. It's an exe.
0
 

Author Comment

by:j055
ID: 21759042
Oh, I just copied the MyHost.exe file to the bin folder and the test seems to work. I don't understand why however.

Thanks
Andrew
0
 
LVL 29

Accepted Solution

by:
Gautham Janardhan earned 500 total points
ID: 21759119
the dll's shud be in the same folder as the exe... otherwise u shud specifically mention the path to the dll's
in ur case first time the exe was in the host folder while dll was in the bin folder
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C# TextBox 11 30
how to truncate multiple tables from SQL Server Database using Stored procedure 8 50
C# application error "Parameter Is Not Valid". 3 80
Runtime Error 2 29
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now