Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

System.Activator.CreateInstance

Posted on 2004-04-21
4
705 Views
Last Modified: 2008-02-01
I am trying to create an object that implements a standard interface.
I am using the following method

    Function CreateComponentInstance(ByVal strAssembly As String, ByVal strType As String) As FTServiceInterface.IFTGenericService
        Return System.Activator.CreateInstance(System.IO.Path.GetFileNameWithoutExtension(strAssembly), strType).Unwrap
    End Function


I am always getting the following error

File or assembly name Test, or one of its dependencies, was not found.

But the file is definatley there!

I am calling using

dim objTest as FTServiceInterface.IFTGenericService
objtest = CreateComponentInstance("D:\DotNetCode\Generic Service\Test\bin\Test.dll","Test.Class1")

What could i be doing wrong?
0
Comment
Question by:crazyman
  • 3
4 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 10880433
What version are you using (2002 or 2003)?

Bob
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 10880492
Actually, you need to run ILDASM, open the assembly Test.dll, and double-click on the M A N I F E S T entry at the top.  When you look at it, it shows entries like:

.assembly extern mscorlib
.assembly extern System
.assembly extern System.Windows.Forms
...

These are the external references to assemblies that the program needs to locate in order to run.  

Bob
0
 
LVL 13

Author Comment

by:crazyman
ID: 10896865
This seems to work passing the full file name...


Function CreateComponentInstance(ByVal strAssembly As String, ByVal strType As String) As FTServiceInterface.IFTGenericService
        Return System.Activator.CreateInstanceFrom((strAssembly), strType).Unwrap
    End Function
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 10903854
Good point.   Full path names are best.  The assembly just needs to be in a place that can be located.  It is usually in the same directory as the executing assembly.  For ASP.NET, it is usually in the Bin directory for the web site.

Bob
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question