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

  • SEARCH
  • Home
  • 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 6589193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:08:31+00:00 2026-05-25T17:08:31+00:00

In Visual Studio 2010 I have the following project layout: Solution project A class

  • 0

In Visual Studio 2010 I have the following project layout:

  • Solution
    • project A
      • class C
      • class D
    • project B
      • T4 template

The T4 template contains a assembly reference like this:

<#@ assembly name="$(SolutionDir)\A\bin\Debug\A.dll" #>

The template instantiates an instance of class C. When I run the T4 template the processor loads the project A’s dll and correctly creates the output. The error arises when I want to change something in project A, say modify either class C or D.

Unable to copy file “obj\Debug\A.dll”
to “bin\Debug\A.dll”. The process
cannot access the file
‘bin\Debug\A.dll’ because it is being
used by another process.

The only way I found to get rid of this error is to restart Visual Studio. Is there any other way to force the unloading of the A.dll assembly from VS?

  • 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-25T17:08:31+00:00Added an answer on May 25, 2026 at 5:08 pm

    Im using VS2010 SP1 and was still getting blocked during build after first build when running a custom T4 template during the POST-BUILD events which accessed instances of classes of the same project.

    How I got it to work was to use Reflection to access classes from the Project dll.

    I still got the blocking issue when loading the dll directly from the file.

    NOTE: The trick was to load the .dll into memory as a byte array and then load the assembly from the raw byte array. DONT load from the file using the Assembly.LoadFrom

    This code is from my T4 template file and is accessing a static class “Information” and calling a static Method “Version” to return a string value.

    string assemblyPath = Path.Combine(projectPath, @"bin\SampleProject.dll");
    byte[] data;
    
    using (var fs = File.OpenRead(assemblyPath))
    {
        data = new byte[fs.Length];
        fs.Read(data, 0, Convert.ToInt32(fs.Length));
    }
    
    if (data == null || data.Length == 0)
    {
        throw new ApplicationException("Failed to load " + assemblyPath);
    }
    
    var asm = Assembly.Load(data);
    appVersion = (string) asm.GetType("SampleProject.Information").GetField("Version").GetValue(null);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Website Project in Visual Studio 2010 along with a Class Library
I have an Visual Studio 2010 ASP.Net project. And I want to deploy this
I have a C# (Visual Studio 2010) project that opens Internet Explorer 8 like
I have a Visual Studio 2010 Deployment Project with the following settings: DetectNewerInstalledVersion =
When building a Windows Forms project in Visual Studio 2010 I have a following
Hi, I have done the following : Start Visual Studio 2010 New Project >
I have a web application solution existing under Visual Studio 2010. Part of this
I am using Visual Studio 2010 ultimate and have a solution that contains a
I have created a sample c++ project under Visual Studio 2010 with following files.
In my Visual Studio 2010 project I have files with .mm file extension, that

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.