Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / September 2006

Tip: Looking for answers? Try searching our database.

C# VBA DLL issues

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
temporalis@gmail.com - 10 May 2006 19:01 GMT
[I've also asked this question in
microsoft.public.dotnet.languages.csharp, and
microsoft.public.excel.programming.  If there is somewhere else that
may be able to help, please point me in the right direction!]

I've created a DLL in C# (VS2005, using .NET framework 2.0) for use
with Excel XP (to provide some business logic, as well as connectivity
to various components of our business applications).  The same DLL is
also to be used with Project 2003.  I've created the DLL as COM
Visible, and registered it properly - it works properly in Project
2003, which is what I've been using to test it (thinking that it would
work fine in Excel as well).

My problem is that now when I try to use the DLL from Excel XP, I get
an error on creating a "new" class from the DLL - and because of this,
I can't use any of the classes in the DLL.

For example:
--------------------------------------------------------
public sub tester()
{
    dim x as myDLL.myTestClass       'Statement 1
    set x = new myDLL.myTestClass  'Statement 2

}

--------------------------------------------------------
Statement 1 executes just fine - intellisense even figures out all the
class members (so if I were to start typing "x.testM", it would figure
out it was "x.testMethod").
Statement 2, however, I get an automation error on - without any
description:
--------------------------------------------------------
"Run-time error '-2146232576 (80131700)':
Automation Error
--------------------------------------------------------

The exact same sub, however, works without any problems at all in
Project 2003.  Note that I don't use any Office Interop libraries (This

is a very simple class I created to test this problem, so it basically
has 1 method that sets the only variable in the class, and has a
default myTestClass() constructor), so I don't know why it doesn't work

in XP.

Would anyone be able to help me here?  Have I somehow used a COM format

that doesn't work with XP?  Does anyhow have an insight that can help?

Thank you in advance!
-  Kurtis W. Story
Bob Eaton - 12 May 2006 04:45 GMT
I'm confused because you said "VBA", but then your example sub didn't appear
to be VBA...

I use my C# assembly in VBA, but with the CreateObject statement; not "new"
(but perhaps you're using something newer than I am...)

   Dim x as MyDLL.myTestClass
   Set x = CreateObject("myDLL.myTestClass")

(I'm not an expert, but...) the other thing to look at would be whether you
can define your C# assembly as AutoDual, I recall about 1000 years ago
(programmer time) that we needed to do that with COM servers being used in
VB(A) script.

Bob

> [I've also asked this question in
> microsoft.public.dotnet.languages.csharp, and
[quoted text clipped - 48 lines]
> Thank you in advance!
> -  Kurtis W. Story
temporalis@gmail.com - 12 May 2006 16:21 GMT
Bob,

Thanks for the reply!  I had been trying all of the definitions for the
assembly, but none of them worked.  However, I found a solution to the
problem.

While I was not programming an Office "add-in, smart document, or smart
tag", I tried the solution here
http://support.microsoft.com/kb/908002/, and it was able to correct the
issue.  This didn't come up when I tried to update Office through
Windows / Office update, which was strange, but now everything works
fine!

I did end up switching to AutoDual in the end, to make other parts work
nice, even though MS doesn't recommend that approach.

Thanks for the help!

-  Kurtis W. Story
Maksym - 19 Jul 2006 23:24 GMT
I had the same issue but with the library copiled in VB.net 2005 for Excel 2002 (XP) and your solution worked!
Spent 2 days wondering what I am doing wrong and searching the net.
Many thanks!

As far as I understand, this is VS 2005 problem only. I compiled a library with VS 2002 and it worked fine with .net version 1.x
katzky - 19 Sep 2006 15:38 GMT
I'm have this same problem.  I read the KB but it did not seem to work.  
What, exactly, did you do to correct this problem?

Thanks.

> I had the same issue but with the library copiled in VB.net 2005 for Excel 2002 (XP) and your solution worked!
> Spent 2 days wondering what I am doing wrong and searching the net.
[quoted text clipped - 4 lines]
> ---
> Posted via www.DotNetSlackers.com

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.