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: 'IServiceProvider' : ambiguous symbol"
Any suggestions on how to get my dll working. 5 7296
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**************@exisconsulting.com
"Duncan Winn" <te**@test1.co.uk> wrote in message
news:%2***************@tk2msftngp13.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: 'IServiceProvider' : ambiguous symbol"
Any suggestions on how to get my dll working.
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?
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**************@exisconsulting.com
"Duncan Winn" <te**@test1.co.uk> wrote in message
news:eq**************@TK2MSFTNGP10.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???
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**************@exisconsulting.com
"Duncan Winn" <te**@test1.co.uk> wrote in message
news:um**************@TK2MSFTNGP11.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...
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\\CPPTYest2\\CPPTYest2\\CDFS vrMS.dll>
using namespace System;
using namespace System::Runtime::InteropServices;
typedef void* HWND;
[DllImport("D:\\provider\\CDFProv\\CPPTYest2\\CPPTY est2\\CDFSvrMS.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);
} This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
| |