473,386 Members | 1,644 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

COM createobject query

Hi all

upgrade a VB6 Project, and am now stumped.

The project contained 4 class modules. These were upgraded from :

Public Class HTMLMail

to :

<System.Runtime.InteropServices.ProgId("HTMLMail_N ET.HTMLMail")> Public
Class HTMLMail

My code gets a string from the registry (I had to rewrite my registry
handlers to dump the API), and attempts this :

sClass = GetString()
objClass=CreateObject(sClass)
objClass.MyMethod() <--------------------

This line fails with a System.IO.Runtime.Exception "Path not found".

If I replace the CreateObject with Dim objClass as new HTMLMail then all is
well.

Obviously I have missed a subtlety here of the upgrade ...

I want to keep this way of working, as it allows me to introduce new
features (i.e. paid for) by simply putting additional DLLs on the client
machine - No DLL, no feature ! Additionally I can maintain features
independently ...

Thanks in advance

Jethro


Nov 20 '05 #1
4 1791
On Thu, 6 May 2004 14:48:59 +0000 (UTC), Jethro wrote:

I want to keep this way of working, as it allows me to introduce new
features (i.e. paid for) by simply putting additional DLLs on the client
machine - No DLL, no feature ! Additionally I can maintain features
independently ...


AFAIR, Late binding is not supported in VB.Net. The best way to handle
your situation is to have each .dll implement an interface (for example
IFeature).

Then, when your main program loads, it can scan the 'feature folder" for
the .dll's that implement the interface.

It works well and you get the benefit of compile time checking of the code.

HTH

--
Chris

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
Nov 20 '05 #2
> Hi all

upgrade a VB6 Project, and am now stumped.

The project contained 4 class modules. These were upgraded from :

Public Class HTMLMail

to :

<System.Runtime.InteropServices.ProgId("HTMLMail_N ET.HTMLMail")> Public
Class HTMLMail

My code gets a string from the registry (I had to rewrite my registry
handlers to dump the API), and attempts this :

sClass = GetString()
objClass=CreateObject(sClass)
objClass.MyMethod() <--------------------

This line fails with a System.IO.Runtime.Exception "Path not found".

If I replace the CreateObject with Dim objClass as new HTMLMail then all is well.

Obviously I have missed a subtlety here of the upgrade ...

I want to keep this way of working, as it allows me to introduce new
features (i.e. paid for) by simply putting additional DLLs on the client
machine - No DLL, no feature ! Additionally I can maintain features
independently ...


In answer to the previous answer ...

ADODB recordsets are being created OK using "CreateObject" ....
Nov 20 '05 #3
I think CreateObject is only to be used with objects that are com objects
(your class is now a .net class) - try this instead:
System.Reflection.Assembly.GetCallingAssembly.Crea teInstance(sClass) - note
that sClass will have to have the full path of the class's type - see this
example:
Module Module1

Class c1

End Class

Sub Main()

MsgBox(System.Reflection.Assembly.GetExecutingAsse mbly.CreateInstance("Conso
leapplication6.module1+c1", True) Is Nothing)
End Sub

End Module

My test app had a root namespace Consoleapplication6, and the class c1 was
nested inside a module - hence namespace.nestingtype+classname
the true argument makes it case insensitive.

Hope that helps,
Alex

--------------------
From: "Jethro" <Je*******@hotmail.com>
Newsgroups: microsoft.public.dotnet.languages.vb
Subject: COM createobject query
Date: Thu, 6 May 2004 14:48:59 +0000 (UTC)
Organization: BT Openworld
Lines: 41
Message-ID: <c7**********@hercules.btinternet.com>
NNTP-Posting-Host: host81-134-26-83.in-addr.btopenworld.com
X-Trace: hercules.btinternet.com 1083854939 4292 81.134.26.83 (6 May 2004 14:48:59 GMT)X-Complaints-To: ne*************@lists.btinternet.com
NNTP-Posting-Date: Thu, 6 May 2004 14:48:59 +0000 (UTC)
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MSMail-Priority: Normal
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA05.phx.gbl!TK2MSFT NGP08.phx.gbl!newsfeed00.s
ul.t-online.de!t-online.de!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!n
ewshosting.com!nx01.iad01.newshosting.com!news-peer0-test!btnet-feed5!btnet!
news.btopenworld.com!not-for-mailXref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.languages.vb:200962
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

Hi all

upgrade a VB6 Project, and am now stumped.

The project contained 4 class modules. These were upgraded from :

Public Class HTMLMail

to :

<System.Runtime.InteropServices.ProgId("HTMLMail_ NET.HTMLMail")> Public
Class HTMLMail

My code gets a string from the registry (I had to rewrite my registry
handlers to dump the API), and attempts this :

sClass = GetString()
objClass=CreateObject(sClass)
objClass.MyMethod() <--------------------

This line fails with a System.IO.Runtime.Exception "Path not found".

If I replace the CreateObject with Dim objClass as new HTMLMail then all is
well.

Obviously I have missed a subtlety here of the upgrade ...

I want to keep this way of working, as it allows me to introduce new
features (i.e. paid for) by simply putting additional DLLs on the client
machine - No DLL, no feature ! Additionally I can maintain features
independently ...

Thanks in advance

Jethro



Nov 20 '05 #4

"Alexandre Moura" <am****@online.microsoft.com> wrote in message
news:E6*************@cpmsftngxa10.phx.gbl...
I think CreateObject is only to be used with objects that are com objects
(your class is now a .net class) - try this instead:
System.Reflection.Assembly.GetCallingAssembly.Crea teInstance(sClass) - note that sClass will have to have the full path of the class's type - see this
example:
Module Module1

Class c1

End Class

Sub Main()

MsgBox(System.Reflection.Assembly.GetExecutingAsse mbly.CreateInstance("Conso leapplication6.module1+c1", True) Is Nothing)
End Sub

End Module

My test app had a root namespace Consoleapplication6, and the class c1 was
nested inside a module - hence namespace.nestingtype+classname
the true argument makes it case insensitive.

Hope that helps,
Alex

This is starting to make sense ... I have tried this, but I suspect I
haven't got the module name correct .... There is no module declaration in
the file, just the :

<System.Runtime.InteropServices.ProgId("HTMLMail_N ET.HTMLMail")> Public
Class HTMLMail

declaration ...

This file is part of my main project ("assembly now"), which is called
"Webupload". In VB6, I just instansiated "Webupload.HTMLMail", which was
compiled into my ActiveX exe.

The reason I did this is so that I could release a "core" functionality to
all clients, and those that paid extra could recieve DLLs which would
contain additional classes that enhanced functionality, however the core
module contains code which is identical for
all classes (file handling etc).

If the whole thing had been written in VB.NET I would have created a base
class, and then inherited from it, so that each derived class could use
functions created in the base class ... even better I would have used VC++
.... however I "inherited" the project, and a complete rewrite is not a
priority .....

thanks for the help
Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: wk6pack | last post by:
Hi, I'm getting this error on my asp page intermittently. One day it is fine, another day, it crashes a lot. I have searched the web and microsoft on this and they say it is a recordset...
6
by: MacKenzie | last post by:
The statement in an asp page: dim objShell Set objShell = WScript.CreateObject("WScript.Shell") now gives this error: VB err= 424,Object required If I use...
1
by: Raúl Martín | last post by:
I´ve a function in asp that run correctly but If I tried to change it forasp.net in asp: xmlHTTP = CreateObject("Microsoft.XMLHTTP") And I thought to use this sentence for asp.net but the...
12
by: karen | last post by:
Hi all : this is going to be a long post. So i apologize in advance :) i am converting a java program in VB right now. I am a java programmer by trade. so i am no expert in this department. I...
2
by: C Williams | last post by:
Hi, I am having some problems with CreateObject and Powerpoint. I'm working from VB.NET with Powerpoint 2003. The code below is only ever called when powerpoint is already open. It's called...
7
by: dlasusa | last post by:
Sorry if this is the wrong group...I THINK I got to the right place...(oh...and I'm a newbie programmer...so please be gentle) Anyway I have a program that works fine when I run it from within...
0
by: quintesv | last post by:
hi all, Running VS.2003 , framework 1.1. I have a COM object written in Delphi which im trying to call through ASP.NET. The COM object connects to a folder on another machine and opens a...
1
by: Lynn Zou | last post by:
In our system , we use an ASP page to upload files but sometimes it doesnot work as it suppose to do and we found error log in Application Error as: Event Type: Error Event Source: Active...
3
by: Sagar | last post by:
I am working on a project where Server.CreateObject is replaced with CreateObject all over the project. Though I know that this will improve performance in terms of Memory overlhead because of how...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.