473,809 Members | 2,617 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dll files

I have a dll created by MS V C++ version 6 Class. The original files it was
based on were Borland and so this dll was created to use the Borland files
in a MS environment. However I am trying to access it in a .NET
application by adding it as a reference, and it keeps complaining that "a
reference to CDFSvrMS.dll could not be added. This is not a valid assembly
or com component."

I have tried to load up the MS VC++ version 6 project in .NET which seems to
automatically convert the project. However when the dll is re-compiled it
still does not work!

I have also tried to create a new dll from scratch, based on the cpp but it
complains "error C2872: 'IServiceProvid er' : ambiguous symbol"

Any suggestions on how to get my dll working.
Nov 13 '05 #1
5 7310
Duncan,

Does the dll that you are using export c-style functions? If so, then
you can not add a reference to it. You can only add references to COM dlls
or to .NET assemblies. In order to call your functions from your program,
you would have to access them through the P/Invoke layer.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- ni************* *@exisconsultin g.com

"Duncan Winn" <te**@test1.co. uk> wrote in message
news:%2******** *******@tk2msft ngp13.phx.gbl.. .
I have a dll created by MS V C++ version 6 Class. The original files it was based on were Borland and so this dll was created to use the Borland files
in a MS environment. However I am trying to access it in a .NET
application by adding it as a reference, and it keeps complaining that "a
reference to CDFSvrMS.dll could not be added. This is not a valid assembly or com component."

I have tried to load up the MS VC++ version 6 project in .NET which seems to automatically convert the project. However when the dll is re-compiled it
still does not work!

I have also tried to create a new dll from scratch, based on the cpp but it complains "error C2872: 'IServiceProvid er' : ambiguous symbol"

Any suggestions on how to get my dll working.

Nov 13 '05 #2
Nicholas thanks...
Does the dll that you are using export c-style functions?
My dll has methods that return an object (if that is what you mean)?
In order to call your functions from your program, you would have to access them through the P/Invoke layer.


If that was what you meant then how do I use a P/Invoke layer?


Nov 13 '05 #3
Duncan,

In this case, you will have to create managed wrappers for the C++
classes which will expose those classes to .NET. You can not just add a
reference.

For a simple example of how to create a managed wrapper in C++ for .NET,
check out the section of the Managed Extensions for C++ Specification,
section 16.2, titled "__nogc Pointers in Managed Classes", located at (watch
for line wrap):

http://msdn.microsoft.com/library/de...sspec_16_2.asp

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- ni************* *@exisconsultin g.com

"Duncan Winn" <te**@test1.co. uk> wrote in message
news:eq******** ******@TK2MSFTN GP10.phx.gbl...
Does the dll that you are using export c-style functions?
does it have functions in it, like say user32.dll,
(SendMessage, etc, etc), or is it a COM server, which stores object types which you can instantiate (MSHTML, ADO, etc, etc).


I don't think it has c-Style functions in it. It basically contains a

suite of classes that have methods. The methods create instances of some of the
other classes in the dll and then return them???

Nov 13 '05 #4
Duncan,

If your DLL exports functions in the standard manner (STDCALL, for
example), then you can us the P/Invoke layer to access those functions.

--
- Nicholas Paldino [.NET/C# MVP]
- ni************* *@exisconsultin g.com

"Duncan Winn" <te**@test1.co. uk> wrote in message
news:um******** ******@TK2MSFTN GP11.phx.gbl...
Nicholas,

Sorry to mislead you, forget what I wrote before........ I have a dll file compiled in MS Visual C++ 6. It already provides a wrapper for the
classes that I am trying to access. The dll provides methods that do not
return anything they just manage data in the classes based on basic int and string input parameters. However, as stated before, I am having trouble
using the dll.

I am guessing that in this case I can just use P/Invoke as you originally
suggested??? Could I use a C++ dll in C#??? or would I need to re-code my
classes into C++????

Sorry and thanks...

Nov 13 '05 #5
Nicholas,

I have tried to use P/Invoke and it says it can't find my dll, I have tried
to specify the path etc,...here is my code....
#include "stdafx.h"

#using <mscorlib.dll >

#include <tchar.h>

//#include <D:\\provider\\ CDFProv\\CPPTYe st2\\CPPTYest2\ \CDFSvrMS.dll>

using namespace System;

using namespace System::Runtime ::InteropServic es;

typedef void* HWND;
[DllImport("D:\\ provider\\CDFPr ov\\CPPTYest2\\ CPPTYest2\\CDFS vrMS.dll")]

extern "C" void diread(String* id, String* path);

void main(void) {

String* pText = L"Hello World!";

String* pCaption = L"D:\\FUMS\\cdf _db\\Historical
Fault View";

diread(pText, pCaption);

}
Nov 13 '05 #6

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

Similar topics

2
14171
by: Mike | last post by:
I am sure that I am making a simple boneheaded mistake and I would appreciate your help in spotting in. I have just installed apache_2.0.53-win32-x86-no_ssl.exe php-5.0.3-Win32.zip Smarty-2.6.7.tar.gz on a system running WindowsXP SP2. Apache and PHP tested out fine. After adding Smarty, I ran the following http://localhost/testphp.php
44
4076
by: Xah Lee | last post by:
here's a large exercise that uses what we built before. suppose you have tens of thousands of files in various directories. Some of these files are identical, but you don't know which ones are identical with which. Write a program that prints out which file are redundant copies. Here's the spec. -------------------------- The program is to be used on the command line. Its arguments are one or
0
6146
by: Tom Lee | last post by:
Hi, I'm new to .NET 2003 compiler. When I tried to compile my program using DEBUG mode, I got the following errors in the C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7 \include\xdebug file as folows. I need help to resolve them ASAP: cl /c /nologo /MDd /W3 /Od /GR /GM /Zi /GX /D "_DEBUG" /D " WIN32" /D "_W INDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_MBCS" /D "_USRDLL" /
18
3190
by: JKop | last post by:
Here's what I know so far: You have a C++ project. You have source files in it. When you go to compile it, first thing the preprocessor sticks the header files into each source file. So now you have your ".cpp" files all ready, without any "#include" or "#define" in them. Let's assume that there's 2 source files in this project, "a.cpp" and
3
3100
by: pooja | last post by:
Suppose i have created a class c1 with f1()in c1.cpp and included this c1.cpp in file1.cpp file , which is also having main() by giving the statement #include "c1.cpp". the same i can do by using header file. i can create a class c1 with f1() in c1.h and include this c1.h in file1.cpp by giving the statement #include "c1.h" tell me that what exactly is the difference between c1.h and c1.cpp? Since they both are doing the same things.
11
5614
by: ambika | last post by:
Iam just trying to know "c". And I have a small doubt about these header files. The header files just contain the declaration part...Where is the definition for these declarations written??And how does that get linked to our program when we run it??I would appreciate any helpful info..And I would like to thank you for that in advance -ambika
22
3021
by: Daniel Billingsley | last post by:
Ok, I wanted to ask this separate from nospam's ridiculous thread in hopes it could get some honest attention. VB6 had a some simple and fast mechanisms for retrieving values from basic text files, which in turn could be simply and easily maintained with notepad. I understand the benefits of XML, really, but in the case of configuration files it seems it is almost always nothing more than unnecessary complexity, both in accessing them...
18
2307
by: UJ | last post by:
Folks, We provide custom content for our customers. Currently we put the files on our server and people have a program we provide that will download the files. These files are usually SWF, HTML or JPG files. The problem as I see it - if you know the name of the file, you could download it off the server (currently we are using an HTTP/Get but I'm going to be using WebClient in the new version.) If there any way to password protect the...
0
1515
by: wal | last post by:
How does one attach files to emails using libgmail? The following code http://pramode.net/articles/lfy/fuse/4.txt works fine when said files are simple text files, but it failes as soon as the files are wild binary files, even attaching the source of an email in a text file (.eml files) failes. What am I missing here? Any hints? The output I get when attemting to send binary files using the code above is pasted below. have fun,
3
5200
by: aRTx | last post by:
I have try a couple of time but does not work for me My files everytime are sortet by NAME. I want to Sort my files by Date-desc. Can anyone help me to do it? The Script <? /* ORIGJINALI
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10387
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7662
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5689
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.