Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3224006
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:10:22+00:00 2026-05-17T16:10:22+00:00

I have an assembly on a shared folder (UNC-path only, no mapped drive). When

  • 0

I have an assembly on a shared folder (UNC-path only, no mapped drive). When I try to register it programmatically via RegistrationServices, I’m getting a strange error.

Here’s the code:

using System;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;

namespace BLRegisterAssembly
{
    public static class BlRegisterAssembly
    {
        public static void Register()
        {
            var asm = Assembly.LoadFile(@"\\myUNCPath\myAssembly.dll");
            var rs = new RegistrationServices();
            rs.RegisterAssembly(asm, AssemblyRegistrationFlags.SetCodeBase);
            // I've also tried AssemblyRegistrationFlags.None : same error.
        }
    }
}

This is the error I’m getting:

“Could not load file or assembly
‘[xxxxxxxxxxxxx],
Version=1.0.0.0, Culture=neutral,
PublicKeyToken=[xxxxxxxxxxxxxx]’ or
one of its dependencies. The system
cannot find the file specified.”

(The file in question is a referenced assembly that the main assembly uses).

Some more points:
– the referenced assembly is located in the same folder as the main assembly that I’m trying to register.
– the folder cannot be mapped as a logical drive. Because of how the network folders are accessed, users in different groups have different drive mappings to the same network folders, and these cannot be modified, per IT policy…

Can anyone point me in the right direction to resolve the problem?

ANSWERED
Because I was using Assembly.LoadFile, the dependent assemblies have to be resolved manually via AssemblyResolve. The following code update fixed my woes:

public void Register()
{
    AppDomain.CurrentDomain.AssemblyResolve += 
      new ResolveEventHandler(CurrentDomain_AssemblyResolve);

    var asm = Assembly.LoadFile(Path.Combine(m_path, assemblyName));
    var rs = new RegistrationServices();
    rs.RegisterAssembly(asm, AssemblyRegistrationFlags.SetCodeBase);
}

static Assembly CurrentDomain_AssemblyResolve(object sender, 
  ResolveEventArgs args)
{
    //... code to resolve the path and load the dependent assembly...
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T16:10:23+00:00Added an answer on May 17, 2026 at 4:10 pm

    You should never use LoadFile(), use LoadFrom() so the CLR has a shot at finding any dependent assemblies. If you still have trouble then use Fuslogvw.exe to get a trace of the assembly resolution attempt. The backup plan is to implement AppDomain.AssemblyResolve.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Assembly [AssemblyName] must have a shared name to be installed globally I am getting
In brief: Is it ever excusable to have assembly names and class names stored
I have an assembly which should not be used by any application other than
I have an assembly, written in C++\CLI, which uses some of enumerations, provided by
I have an assembly containing very thorough XML-based documentation, which is used through Sandcastle
I have an assembly that may be used by more than one process at
I have an assembly. Is there a way to detect which version of .NET
I have an assembly that is targeted for .NET 3.5. I have an application
If I have an assembly (A) which references another assembly (B). I want to
I saw something about needing to have the assembly available for the type of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.