Search:
Namespaces
Discussions
.NET v1.1
Feedback
AssemblyBuilder.Save() System.IO.IOException
Messages
Related Types
This message was discovered on
ASPFriends.com 'ngfx-reflection' list
.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Joel Haugen
I have created a dynamic assembly in a web application with the
AssemblyBuilderAccess
.RunSave. When I attempt to save the assembly using
something like:
assemblyBuilder.Save("MyDynamicAssembly.dll");
I get a System.IO.IOException: Access denied. What do I need to configure
to be able to write the dll? I assume it is trying to write the web app's
bin directory.
Reply to this message...
Saurabh Nandu (VIP)
Are you setting the path to where you want to save the assembly ?
Since as far as I remember, in case you are running a web application,
Reflection.Emit's default 'Save' method saves the assembly in the
C:\Winnt\ (some sub-folder .. I forgot) .. and since you might not have
write access to that folder you are getting this error.. I guess you can
give the full path to save the file while calling the method
DefineDynamicModule on the
AssemblyBuilder
instance..
Regards,
Saurabh Nandu
[Microsoft MVP]
www.MasterCSharp.com
Master C#, the easy way...
[Original message clipped]
Reply to this message...
Joel Haugen
An odd resolution:
I am running XP Pro. I wanted to turn on auditing to determine the exact
nature of the IO failure. To do this, I had to enable the security tab on
the folder properties window by disabling simple sharing (Windows
Explorer -> Tools -> Options -> View). Somehow, after this, I was able to
execute
AssemblyBuilder
.Save with no IO exception, even when I switched back
to simple sharing!!
However, this raised a new interesting issue.
You are correct. By default, the assembly is written to your
%SystemRoot%\System32 directory. If I accept this default (i.e., don't
specify a path when I call DefineDynamicAssembly), everything is okay. If I
specify a directory (
AppDomain
.CurrentDomain.BaseDirectory + "bin/"), it
successfully writes to my web app bin directory. However, when I do this,
when I run any page in my web app after saving the assembly, I get the
following error:
Parser Error Message: The located assembly's manifest definition with name
'MyDynamicAssembly' does not match the assembly reference.
Source Error:
Line 170: <add assembly="System.Drawing, Version=1.0.3300.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
Line 171: <add assembly="System.EnterpriseServices,
Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
Line 172: <add assembly="*"/>
Line 173: </assemblies>
Line 174:
Source File:
c:\windows\microsoft.net\framework\v1.0.3705\Config\machine.config Line:
172
Any ideas why?
Reply to this message...
Saurabh Nandu (VIP)
Sorry for the delayed reply ..
The problem might be that the assembly manifest might not contain
correct reference (path problems) to the module you have created ... can
you send me the code snip .. so that I can try things out and find a
solution ??
Regards,
Saurabh Nandu
[Microsoft MVP]
www.MasterCSharp.com
Master C#, the easy way...
[Original message clipped]
Reply to this message...
System.AppDomain
System.IO.IOException
System.Reflection.Emit.AssemblyBuilder
System.Reflection.Emit.AssemblyBuilderAccess
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com