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 936423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:18:43+00:00 2026-05-15T21:18:43+00:00

I’m working on a .NET library that is intended to be consumed in a

  • 0

I’m working on a .NET library that is intended to be consumed in a VB6 project. To set up the dll to be used on my developer machine, I use regasm and gacutil, like so:

regasm /tlb:MyDll.tlb Mydll.dll 

gacutil /i Mydll.dll 

On each subsequent call, I also unregister/uninstall the assembly:

regasm /u /tlb:MyDll.tlb Mydll.dll
regasm /tlb:MyDll.tlb Mydll.dll 

gacutil /u Mydll
gacutil /i Mydll.dll 

Currently, I’m doing this from the Visual Studio Tools command prompt. Is there a way to script these commands into one execution path?

NOTE: This script is intended only for my developer machine where regasm and gacutil are both readily available.

  • 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-15T21:18:44+00:00Added an answer on May 15, 2026 at 9:18 pm

    Here’s how I ended up automating the process of registering and GAC-ing my dll.

    First, I created a directory in the root folder of the solution called “ScriptedDevDellRegistration”. I copied the most recent versions of gacutil.exe and RegAsm.exe (with their corresponding .config files) into this directory.

    Next, I added a file into that directory called RegDll.cmd. This file will register the dll with its tlb and then install it in the GAC. This is useful when needing to consume an assembly in the VB6 development environment via COM interop. The file’s contents are:

    cd "%~dp0"
    regasm MyDll.dll /tlb:MyDll.tlb /u
    regasm MyDll.dll /tlb:MyDll.tlb
    
    gacutil /u MyDll
    gacutil /i MyDll.dll   
    

    I also added a file called UnGacDll.cmd that will uninstall the assembly from the GAC. When running a console test application that uses an assembly in a different project, and that assembly has been added to the GAC, I’ve had trouble getting debug to work. This file simply removes the dll from the GAC so that I can debug more easily:

    cd "%~dp0"
    gacutil /u MyDll
    

    Now that I’ve got my files set up, I need to edit the Build Events of my project.

    In the project’s properties (I’m using VS2010 with VB.NET) for the assembly being compiled and registered/GAC’d, click the compile tab and click the “Build Events” button. In the post-build events, add code that is similar to the following:

    IF not "$(ConfigurationName)" == "Release Scripted Dev Dll Registration" GoTo elseIf1
    :default
    COPY "$(TargetPath)" "$(SolutionDir)ScriptedDevDllRegistration\$(TargetFileName)"
    "$(SolutionDir)ScriptedDevDllRegistration\RegDll.cmd"
    GOTO exit
    :elseIf1
    IF not "$(ConfigurationName)" == "Debug ConsoleTest" GoTo elseIf2
    "$(SolutionDir)ScriptedDevDllRegistration\UnGacDll.cmd"
    GOTO exit
    :elseIf2
    IF not "$(ConfigurationName)" == "Debug Console Web Library" GoTo exit
    "$(SolutionDir)ScriptedDevDllRegistration\UnGacDll.cmd"
    GOTO exit
    :exit
    

    The cmd scripting is kinda ugly, but very useful. I use different build configurations to drive which scripts get executed in the post-build events. For example, the first line looks for a build configuration named “Release Scripted Dev Dll Registration”, which copies the DLL to the subdirectory I made and then executes RegDll.cmd to register the assembly and its type libraries as well as GAC the assembly.

    The other configurations, “Debug ConsoleTest” and “Debug Console Web Library,” work best when the dll is not in the GAC, so the post-build event calls UnGacDll.cmd for those configurations.

    I’m sure it’s possible to script some of this functionality without physically copying dll’s or the regasm.exe or gacutil.exe utilities, but the solution I explained above worked well for me.

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

Sidebar

Related Questions

No related questions found

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.