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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:22:08+00:00 2026-05-15T12:22:08+00:00

I have the following procedure private static IMyInterface OpenInstance( string assemblyPath, string classType, string

  • 0

I have the following procedure

private static IMyInterface OpenInstance( 
string assemblyPath, 
string classType, 
string assemblyName, 
out AppDomain domainInstall)
{
   IMyInterface interface = null;

   AppDomainSetup domaininfo = new AppDomainSetup();

   domaininfo.ApplicationBase = assemblyPath;
   domainInstall = AppDomain.CreateDomain("PathInstall", null, domaininfo);

   ObjectHandle handleService = null;
   try
   {

      handleService = Activator.CreateInstance(
      domainInstall,
      assemblyName,
      classType,
      true,
      System.Reflection.BindingFlags.CreateInstance,
      null,
      new Object[] { assemblyName},
      System.Globalization.CultureInfo.CurrentCulture,
      null, null);

      Object myobject = handleService.Unwrap();
      interface = (IMyInterface )myobject ;
    }
    catch (Exception ex)
    {
       ...
    }

    return interface ;
}

This procedure works ever fine, but when it is called during an installation custom action.

In other words if i call my OpenInstance(…) procedure inside my own Install(…) override:

public override void Install(IDictionary stateServer)

Defined in my Installer extended class:

[RunInstaller(true)]
public class SpheresServiceInstaller : Installer

I got an exception when i try to cast my unwrapped object to the desired type:

interface = (IMyInterface)myobject ;

Exception details:

  • Type: System.InvalidCastException
  • Message: Unable to cast transparent proxy to type ‘IMyInterface’.

I would like to understand why the procedure works ever but in this specific case.

Details

  • I followed step by step the object creation procedure and everything seems fine, the object is well created by the Activator.CreateInstance procedure.

  • The assembly, which is used by the Activator.CreateInstance, already exists on the file system.

  • The specific assembly ‘assemblyName on the source code) is a window service that has been just created by the installation procedure.

  • 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-15T12:22:08+00:00Added an answer on May 15, 2026 at 12:22 pm

    I solved the problem following the link proposed at this post

    stack overflow: appdomain-createinstancefromandunwrap-unable-to-cast-transparent-proxy

    The link that gives us the solution code is

    west-wind.com: Assembly Loading across appdomain

    It is really a basic thing, i was falled in the case where an assembly is loaded by an external application (in my specific case: the wow64 installer application).

    The application does not know where to find the assemblies that depend from the main assembly you are loading, so you have to write a custom assembly resolver for the current application domain (in my specific case: the wow64 installer application) in order to give the necessary loading information inside it.

    Head to the west-winf link to get the code, it works perfectly

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

Sidebar

Ask A Question

Stats

  • Questions 531k
  • Answers 531k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer In the UIViewController class reference, Apple recommends that for iOS… May 16, 2026 at 11:53 pm
  • Editorial Team
    Editorial Team added an answer Right before invoking addMessage(), call Thread.currentThread().interrupt(). This will set the… May 16, 2026 at 11:53 pm
  • Editorial Team
    Editorial Team added an answer I am assuming that the executions of db.readTransaction and tx.executeSql… May 16, 2026 at 11:53 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have the following classes: type TSong = class(TObject) private FArtist: String; FTitle: String;
I have the following in a stored procedure: DECLARE @new_column_name varchar(9) DECLARE @table_name varchar(16)
I have the following c# code to call stored procedure testproc , but when
Let's say I have the following two tables: Fields FieldID INT FieldName NVARCHAR(50) Values
I have the following tables structure: Shipment (has IDDestination as foreign key) -> Destination
I have the following declaration for DNSServiceRegister: function DNSServiceRegister ( var sdRef: TDNSServiceRef; const
I have the following sample code where I download a pdf from the European
I am trying to override the window procedure for the winmobile taskbar (in order
I was told more than once that Delphi handles dynamic classes better than static.Thereby
I have a large data file, which is zipped, and approximately 20MB. When it's

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.