Home » .Net Framework

regasm 4.0 generates error for DLL on a mapped network drive

Calling regasm from .NET Framework 4.0 generates an error for a DLL that is on a mapped network share.  This occurs during our debug builds on developer machines (we actually call a utility that wraps around regasm to perform COM-based registration).  The error is:

RegAsm : error RA0000 : Could not load file or assembly 'file:///m:\<file being regasmed>' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)

I can work around this issue by modifying regasm.exe.config to include the loadFromRemoteSources element.  This seems like an annoying change for something that seems like a fairly common task.

Is there some better way to enable this?




14 Answers Found


Answer 1

It is possible that the account you are using to execute builds  does not have the relevant drive  mapping.

I would opt for UNC paths, e.g. \\server1\path\file.

My questions are:

Can you try a UNC path instead? Does that regasm  command work  using an interactive login? (i.e. checking that dependencies  are accessible) Can you interactively login with the same account that the build is using and run the command?


Answer 2

The drive  is mapped  to M: as we use ClearCase as our source control system.  If you're using a dynamic view, that's how it works.

The execution is occurring in an interactive login.  This is simply a developer  running a compilation in Visual Studio.  The end of the compilation kicks off our utility  that tries to call  regasm.  regasm fails with the message in my original email.


Answer 3

It would be better if you could post the command and parameters that you are running against regasm.

The tlb parameter should point to a folder that will be available when any user attempts to instantiate the registered library.

While it is possible to keep the library on a network  drive, it is not recommended, unless it is DCOM.

Another thing to concern yourself with is code access security. When an executable is loaded from a network drive  the CAS is downgraded to partial trust. If your library requires full trust, it won't work.

You can try this test. Create a new VS project. Add a reference to the library on the remote drive and change  it to "Copy local = false". Make sure there are no local copies. Can the VS project successfully use that library?


Answer 4


I took a look at this and reproduced it as well. Based on what I found, it appears to be due to the security changes for the CLR in .NET 4.0. For more information, take a look at this link:


What's happening is that when Regasm.exe attempts to load  the assembly  on the remote share, it fails with a FileLoadException with an inner System.NotSupportedException. Here is the relevant output from when I debugged this on my machine.

0:000> !pe 029d99a4
Exception object: 029d99a4
Exception type:   System.NotSupportedException
Message:          An attempt was made to load an assembly from a network  location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable  CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.
InnerException:   <none>
StackTrace (generated):
StackTraceString: <none>
HResult: 80131515

Note the NotSupportedException points you to the relevant help topic which discusses the use of <loadFromRemoteSources> in the application's config  file.

It looks like you are already doing that, so if your utility  is going to spawn regasm.exe directly then I think you already have the best solution.

Another solution would be if you could simply check the option in Visual Studio for "compile with COM Interop". This seems to work  for me when building the DLL to the remote location (VS does not use regasm  when registering an assembly).

Hope this helps,

Keith Fink
Microsoft Communities Support


Answer 5

I found this helpful, thanks  Keith

Answer 6

So the first thing to try is to add the

[assembly: SecurityRules(SecurityRuleSet.Level1)]

attribute to your DLL assembly  properties, effectively switching off .NET4 security-transparent CAS.

If this works, it proves that the problem is about .NET4 CAS. Then you have to decide if you are happy leaving it switched off.


Answer 7

  I'm running into the same problem. [ regasm  was successful over a network  share in .net 3.5.]
  And here's the reason why I would like to use regasm  [and dont have the option modify regasm.exe.config]

Given that my COM interop assembly  [strong named] has to be registered [ as part of a product] for use on other client's machines
 while deploying, ideally I would like to continue using regasm [or some equivalent].

Also, technically if regasm is loading strong named assemblies , should this load  be successful or any different ?

Finally what are the alternate solutions to regasm ?

1. I create a myproduct.reg file  and am thinking of running it with the unc path since that does not involve regasm loading the exe  over a network.

2. [assembly: SecurityRules(SecurityRuleSet.Level1)]
   attribute to your DLL assembly properties, effectively switching off .NET4 security-transparent CAS.

   Where do I do this, is this an entry in AssemblyInfo.cs ?

3. Using VS [2010] to compile with COM interop.
   Dont seem to see this option on project properties. Is this the COMVisible attribute in AssemblyInfo.cs that you are referring to  ?

   >> Another solution would be if you could simply check the option in Visual Studio for "compile with COM Interop".
   >> This seems to work  for me when building the DLL to the remote location
   >> (VS does not use Regasm when registering an assembly).

   What does VS use for registering COM interop assemblies [other than regasm?]

   Any feedback will be really helpful.


Arun M


Answer 8


(1) Your registry file  may successfully add the entries into to registry, but code access security will still be a problem when your calling  client tries to instantiate it.

(2) Yes, in the AssemblyInfo

(3) I think the regasm  tool does this for you. The only thing I can think of that helps COM interop registration  is the GUID specified in the GuidAttribute and the type specified in the InterfaceTypeAttribute of the AssemblyInfo.


Answer 9

Just a minor note on #3, VS does not use Regasm when registering the assembly  for COM. Rather it is done by an in-process call  to RegisterAssembly.


Keith Fink
Microsoft Communities Support


Answer 10

Thx Guys.

  I went with a myproduct.reg solution since that seems to be the only working/practical solution.

Btw, internally wherever my app. was calling  Load/LoadFrom, I've modified it [UnSafeLoadFrom] so that when the app. is loaded/run over a network  it does not have similar issues as regasm  due to .NET 4.0 security changes.


 I guess another option could have been creating my own flavor/version of regasm

using interop registration  services as pointed in the earlier resposnse.





Answer 11

Hello everyone,

I am also facing the same issue  as mentioned above. I try to regasm  a .Net 4 framework  assembly over the network  and am getting the following error:

RegAsm : error  RA0000: Could not load  file or assembly  'filename with path' or one of its dependencies. Operation is not supported. <Exception from HRESULT: 0x80131515>

This used to work  with .Net framework 3.5. I could not understand, the fix mentioned for this problem for .Net 4.0 framework as mentioned above.

Please advise, how to get around this error.









Answer 12

The fix I was explaining was...

Add the


[assembly: SecurityRules(SecurityRuleSet.Level1)]


attribute to your DLL assembly  properties, effectively switching off .NET4 security-transparent CAS. To find this, look in the Properties folder in your project and open the AssemblyInfo.cs file.


Answer 13

Hi Johan,

I tried this out and it still fails for me. The DLL builds  successfully for me, but if I run regasm  against it, it still fails with the same System.NotSupportedException / FileLoadException. Did you try it out? Just wondering if I missed something. Otherwise, the only other solutions I see are:

Use loadFromRemoteSources as Kevin mentioned. Write your "regasm" that calls into RegistrationServices.RegisterAssembly.

Hopefully, I just missed something though; as your solution would be the easiest.


Keith Fink
Microsoft Communities Support


Answer 14


Yes the LoadFromRemoteSources worked for me. In addition, I created my own registration  assembly code and its working fine for me.






  I am geting the above error on a project that i have just moved form vs2005 to vs2010.  I have seen a similar post from 2007 but that pointed to a miss match in .net versions.  I do not belive this is the case here as i have check the version (4.0) and that looks ok. I have also opened the assably using Reflector and can see no problems.   Where should i look now?


When developing a MEF application on a mapped network drive I get an FileLoadException when calling:




  Exception Message "Could not load file or assembly 'StandAlone, Version=, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)" string

I can get the project to work when it is loaded on my local computer. How can I get it to work from the mapped network drive?


I'm trying to access a network share, and authenticate using a smartcard. The smartcard can be used to log on to the server. The client runs Windows XP sp3, with all latest patches installed, the server runs Windows Server 2003. The client is NOT a member of this domain though, because I want to use this method on a standalone device.

On the server PC, running Windows Server 2003, this works just fine:

C:\Documents and Settings\Administrator>net use \\ecoserver.eco.lan\Homes\Administrator /smartcard
Reading smart cards........
Using the card in reader 1.  Enter the PIN:
The command completed successfully.

On a client PC (NOT a domain member), the same thing with the same card fails:

C:\Projects>net use \\ecoserver.eco.lan\Homes\Admnistrator /smartcard
Reading smart cards.....
Using the card in reader 1.  Enter the PIN:
System error 1263 has occurred.

The kerberos protocol encountered an error while validating the
KDC certificate during smartcard logon.

Using plaintext passwords does work:

C:\Projects>net use \\ecoserver.eco.lan\Homes\Administrator /user:Administrator@eco.lan
The password or user name is invalid for \\ecoserver.eco.lan\Homes\Administrator.

Enter the password for 'Administrator@eco.lan' to connect to 'ecoserver.eco.lan':
The command completed successfully.


Things I have checked:
- No error or warning is being logged in the Event Log, not on the server, nor on the client machine.
- I can authenticate to LDAP over TLS with the client certificate from the same smartcard on my client and perform queries.
- My client PC trusts the CA certificate from the domain server, I've imported it into the trusted root CA's.
- I can connect with SSL with IE to the domain server's IIS (which has a certificate signed by that CA), the certificate shows as trusted.
- I tried re-newing the domain controller certificate. No change.

Here goes :
I have a mapped Network drive on my win 7 system. I purposely choosed not to tick "reconnect at logon" cause I don't want the drive to be automatically reconnected.
Problem : at startup, Win 7 logins and all programs relying on the mapped folders are lost.
What I'd want : at startup, have win7 display a credentials input windows and wait until I input them or cancel before proceeding.
Moved byLisa- Support EngineerMSFT, ModeratorFriday, November 20, 2009 10:23 PMwrong forum (From:Files, folders and search)Marked As Answer byCody - Support EngineerMSFT, Moderator4 minutes ago

I'd like to find out all logical drives of a system including the mapped network drives. Unfortunately the function


does not return the mapped network drives. Is there a way to find out them?


Thanks and regards,



I asked this question a few days ago, but my question is gone?! Please, if this is the wrong place to address this question or of some other reason it must be deleted, please tell me what to do first so I can progress with my problem.

Anyway. I've tried to search these forums, google and bing searched all over the web, but for no solution that have worked for me yet.
I cannot figure out how to map sharepoint as a network drive, so that I can access it and use it for storage in Windows Explorer. I can access and use it using Internet Explorer, but that is not what I want.

I own a domain, have purchased sharepoint for that domain, and I used it successfully under Windows XP. After installing Windows 7 Ultimate RTM, I can't get it to work seemingly. I've tried to use the "map network drive" wizard, and manually through right clicking on "Network" in Windows Explorer.

The result every time is that it doesn't spend a second on trying to contact my sharepoint address / site, and it says that "The folder you have entered does not appear to be valid. Please choose another." The address is of the type: http://sharepoint.thenameofmydomain.com
What I want to acheive is the same as I did in Windows XP, where my sharepoint site always where present under Windows Explorer, and where I could browse around in the different sub folder, create / delete / rename folders, and save, open and delete files - just as if it was a local folder on my computer.

I would be very greatfull if someone could either guide me to a place where I can find a solution to this, if it is obvious what I do wrong, or can help me with this problem.


Hi All,

Does TFS upport UNC path

- I mapped a network drive to Z:\ drive on local TFS server machine
- Then created a team project and mapped it to the Z: drive. Then did the the following in VS 2008 CMD:

tf add /r *
tf checkin /r

It added all of my projects to the team project and checked them in successfully. Then to test, I checked out a file on a client machine. Refreshed Source Control Explorer on TFS and it said the client checked out the file. When I tried to open the file in Source Control Explorer on the TFS server machine i got: "TF10187: Coul not open document Z:\Projects\Appliction2011\Main\1.cls. The system cannot find the path specified."

I can browse to this path just fine and open up that file.

Not sure what to do from here...

Please help.

Thank you,


Hi All,

The following code works perfectly on Windows XP - VS2008

                FileStream x = new FileStream(@"S:\Data\SomeFile.xml", FileMode.Open);
            catch (Exception ex)

The drive in question is mapped to a network share.

On Windows 7 64 bit - VS 2008, the same code fails with a DirectoryNotFoundException. If I open the file using the UNC path it works.

I have reasons for wanting to use mapped drives. Can anyone explain why this behaviour has changed and whether there is a workaround?

Many Thanks

Hi All,

The following code works perfectly on Windows XP - VS2008

                FileStream x = new FileStream(@"S:\Data\SomeFile.xml", FileMode.Open);
            catch (Exception ex)

The drive in question is mapped to a network share.

On Windows 7 64 bit - VS 2008, the same code fails with a DirectoryNotFoundException. If I open the file using the UNC path it works.

I have reasons for wanting to use mapped drives. Can anyone explain why this behaviour has changed and whether there is a workaround?

Many Thanks



My project/app involved uploading image file to a share folder or mapped network drive, say Z (example: Z:\root\data . . .), in other words, how to upload image file to a relative path location or mapped network drive instead of absolute path or rooted path. I had tried  the SaveAs and Combine methods which work for absolute path but would fail if try to upload to mapped network drive (error: ... could not find part of the path ...). Thank you.




Is there a way to map network drives within a cluster? For example...

Lets say that node1 has drives a, b, and c mapped to it. When I failover to node2, I would like to have the same drives automatically appear on node2. So once I failover, the drives that are already mapped on node1 will automatically be on node2. Is this possible?

Any help would be appreciated,


1. I have a C++ application that uses GetDriveType() API to retrieve the drive type for the selected drive (list of drives populated in the combo box). 2. I'm using 3 Windows Server 2008 R2 machines e.g. A,B,C, 3. My C++ application runs on machine A. 4. Also on machine A, I have created a network drive mapped to a drive of machine B. 5. When the C++ application is executed directly on A then the GetDriveType() API executes successfully for the mapped network drive and returns DRIVE_REMOTE 6. Now I establish a remote desktop connection(MSTSC) to machine A from machine C and run the C++ application, the GetDriveType() API executes successfully for the mapped network drive and returns DRIVE_REMOTE 7. Now instead of remote desktop connection, I create a RemoteApp setup for the C++ application (.rdp). Now when I execute the remoteapp from machine C, the GetDriveType() API fails to execute and returns DRIVE_NO_ROOT_DIR Can anybody please help me with the below questions - 1. Is there any limitation to RemoteApp for network drive? 2. What is the difference between RemoteApp and Remote Desktop Connection that causes the change in behavior? I also tried Solutions which are mentioned at the following forums, http://www.eggheadcafe.com/software/aspnet/33891358/vista-getdrivetype-return-drivenorootdir-on-network-mapped-drives.aspx http://us.generation-nt.com/answer/vista-getdrivetype-return-drive-no-root- dir-network-mapped-drives-help-28505542.html but none of them worked for me.

Hello All,


Currently I am trying to create a small application which will be used to map a common network drive on an offline computer. Currently my form has:





I have these all setup so that when I click to map the drive it will automatically grab the entered information and map it to the W drive. I tried the code below but it isn't working, stating a W32 exception. Any help would be greatly appreciated!



Public Class frmMap

    Private Sub cmdMap_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdMap.Click

        Dim Location As String

        Dim Username As String

        Dim Password As String

        Dim Domain As String

        Dim Letter As String


        Location = txtLocation.Text

        Username = txtUsername.Text

        Password = txtPassword.Text

        Domain = txtDomain.Text

        Letter = "W:"


        System.Diagnostics.Process.Start("net.exe use " & Letter & " " & Location & " /user:" & Username & " " & Password)

    End Sub


End Class



Thank you!



This is complicated- and try as I might I can't get it right. I am running SBS 2008 SP2 with WSS 3.0 SP3.

I have my sharepoint site at http://companyweb. I have WebClient and WebPublishing services enabled.

The scenario I am trying for:

I have a document library in Sharepoint called Wellness Boxes. Inside this library each domain user has a folder- these folders are to store personal files. Each folder is configured with permissions via Sharepoint so that only the user and their direct manager has access. When a user enters the library, they only see their own folder.

I am trying to map this situation to network places. I want users to be able to click Start>Computer>Network and see a drive labeled Companyweb. Entering that drive will show them the document library Wellness Boxes, and only their own folder will be visible.

I need to do this at a domain level through Group Policy so it applies to all users and all computers. Drive letters do not matter. Permissions do matter.

Can anyone help me please?


Blog@ http://chrisdill.wordpress.com

I am developing in VS2010 a validation tool that needs to look for files on a network share. The files are pathed via a mapped drive. When the code




allFiles = Directory.GetFiles(Path)

is executed, I get the follow exception.

Could not find a part of the path 'I:\active\production\09 Vrod deu\'.

   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileSystemEnumerableIterator`1.CommonInit()
   at System.IO.FileSystemEnumerableIterator`1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler`1 resultHandler)
   at System.IO.Directory.InternalGetFileDirectoryNames(String path, String userPathOriginal, String searchPattern, Boolean includeFiles, Boolean includeDirs, SearchOption searchOption)
   at System.IO.Directory.GetFiles(String path)

I have taken that listed path and in windows explorer been able to access the path without an issue. I am an administrator on the computer trying to run this code. The application is WPF.

I have looked on line and all references are for users not having permissions. Since this is an application and not a web site, it should be using my login which I have proved has access rights.



I am a newbie to vbscripting. The situation is that, i need to map to a network drive. I got the script. The script that i use is as follows and it is working fine now.

Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "Z:", "\\servername\ftp"

I have applied this in the group policy among the logon script. But, this will work only if they connect to the lan cable before they login to the domain.

We have many users who are using laptops in our domain. So, if they already login to the machine, and then connect to the lan cable, this mapping will not work. I need a script, which will check periodically, say 3 min, wheather it is already mapped to a network drive. If it is not, then, i need to execute these commands. If it is already connected, then, this check can be stopped.

Is this possible? Can any one please help me?

Thanks in advance.





I need to create a script task that checks if a network drive has been mapped. If it has not been mapped then I need to map the network drive. Is this possible in .NET?

Any help would be appreciated




I'm trying to map a SharePoint document library to a network drive but I'm getting so errors one is

"The drive could not be mapped because no network was found."

and the other is

"The workstation driver is not installed."

I have no clue what is wrong, connecting from another computer to another server works fine, but from this one i can't connect to any sharepoint document library.

Using the view in explorer from the SharePoint site gives me access to the folder without any problems. So I guess something is wrong on this end.

Running Windows XP Pro SP2 and the Webclient service is started.

Can someone please help? 


Good Day

I have a pdf document (not sure if this is related to the issue) in a WSS2.0 document library.

I am able to open this document from the SharePoint site.

I have a mapped Network Drive to the same library but the same document does not open from the mapped network drive.

Error message: "There was an error opening this document. The network path was not found".

There are other documents (among them office and pdf docs) in the document library and all of them are accessible via the network drive.

Any ideas?


Hi All

When uploading documents to a wss2.0 site through the GUI, users a forced to enter metadata.

However, when uploading documents through a mapped network drive, the mandatory metadata is not enforced.

Any ideas how metadata entry can be enforced?



<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure