Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Scripting / October 2006

Tip: Looking for answers? Try searching our database.

Dynamic Code Referenced Assemblies from ASP.NET

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jeronimo Bertran - 29 Sep 2006 02:52 GMT
Hello,

I have creatred a dll that uses CodeDom to generate and exectue dynamic
code.

Basically the dll creates a new assembly by loading some user defined
code from a database, compiles it and runs it a certain number of times.

The process works very well when I use it from a Windows Forms
application.  I am now trying to use the same dll to invoke dynamic
execution from an ASP.NET page.  I am sure I will run into different
problems, but my first problem is that the compiler is not able to
locate the referenced assemby dll files.   Here is some detail:

CodeDom.Compiler.CompilerParameters compilerParameters;

.....

compilerParameters.ReferencedAssemblies.Add("MyAssembly.dll");

when I try to compile the code using:

compilerResults = provider.CompileAssemblyFromDom(compilerParameters,
codeCompileUnit);

I get an error "Metadata file 'MyAssembly.dll' could not be found.

The file MyAssemby.dll is in the bin directory of the WebSite directory.  
I also tried adding the assembly as "bin/MyAssenby.dll" with the same
result.

Also, once I am able to compile the assembly, is there a specific
location I should use for it?

Thanks,

Jeronimo Bertran
Luke Zhang [MSFT] - 29 Sep 2006 06:36 GMT
Hello,

You may make that the account used by your ASP.NET application has enough
permission to access the folder/files. When lack of permission, there will
be such a file not found error. For example, you may check what the
authentication your ASP.NET application used, and if anonymous and
impersoante is enabled.

Second, you may change the code as following:

compilerParameters.ReferencedAssemblies.Add(Server.MapPath(".")+"\\MyAssembl
y.dll");

Server.MapPath(".") will return the phiscal path of current ASP.NET
application, and this may guide it find the file.

Sincerely,

Luke Zhang

Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Jeronimo Bertran - 29 Sep 2006 23:20 GMT
Luke,

Thanks for your help.   Path.Combine(Using Server.MapPath("."), "bin")
solved the problem.

I am still having some problems invoking the scripts but will look into it
before asking.

Jeronimo Bertran
Luke Zhang [MSFT] - 02 Oct 2006 03:22 GMT
Hello Jeronimo,

Thank you for the information. For any further questions, please feel free
to post in our community.

Sincerely,

Luke Zhang

Microsoft Online Community Support
This posting is provided "AS IS" with no warranties, and confers no rights.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.