|
just expose your C code as managed C++ lib, then Add Reference. i think if you know what you're doing, it's like a hour's work. If your c++ code is managed code, just compile the "managed c++ class library". If not, just cut and paste your c++ code into a managed c++ class library - then compile and get your dll/assembly. After that, you have two options:
1. shared dll (you need to install assembly into GAC - perhaps forget it for now)
2. private dll (That's what you will do, for now)
With option 2, just do this:
1. Project menu
2. Add Reference
3. Browse (select your dll/assembly)
Then, just use it in your c# code:
using namespace XXXXX;
...
...
MyCPlusPlusClass obj = new MyCPlusPlusClass();
...
Just in case you get confused... in your managed class library (which compiles to dll):
namespace XXXXX
{
public class MyCPlusPlusClass //REMEMBER "public"
{
//your stuff
};
}
I don't think you need interop. YOu didnt develop a COM/ATL-server. For newbies, what I described is easiest and it's more efficient (by passing layers of framework code). But, if you wish to explore:
subject: RCW (Runtime callable Wrapper) - Interop
teach yrself C++/VC.net in 24 hours book (publisher: Sams)
good_luck
norm
|
|
|
|
|
Sorry, won't work. In managed C++, class is equivalent to __nogc class , and only __gc classes can be seen from C#.
Like leppie said, I would just create a MC++ wrapper for the functionality I want to expose. For a general idea, take a look at facade design pattern[^]
|
|
|
|
|
Entelecheia wrote:
I am suprised that I can't declare a C++ function as public and have the linker resolve across the two languages.
Why are you surprised? In order to use a type between languages, it must be CLS compliant. C++ functions are not CLS compliant.
|
|
|
|
|
Entelecheia wrote:
I am suprised that I can't declare a C++ function as public and have the linker resolve across the two languages.
I can't imagine why.
Why can't you rewrite the function in C# ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
There is a good artical Here
<marquee behavior="alternate">Bo Hunter
|
|
|
|
|
Hi,
I'm amost finished creating my first C# application
My application connects to a database and I want to be able to change the connectionstring without recompiling.
I have read about the app.config file but I'm having problems making i work
Are there anybody who has some tips, examples or useful links?
modified 23-Jul-20 21:01pm.
|
|
|
|
|
Your configuration file should be named application.exe.config. Replace application with the actual executable name. If you add the configuration file to the project then name it app.config and VS.NET will automatically rename it correctly when it builds the project. The file should look like...
<configuration>
<appSettings>
<add key="ConnectionString" value="the actual string goes here" />
</appSettings>
</configuration>
And in code you can access it with...
ConfigurationSettings.AppSettings["ConnectionString"]
|
|
|
|
|
Great... thanks Brian. Now it finally works 
modified 23-Jul-20 21:01pm.
|
|
|
|
|
How do I hide those, ideas, links, code appreciated
nick
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
Havn't checked, but can this not be done with FormBorderStyle?
|
|
|
|
|
nope only modifying the controlbox but that just greyes out the close button
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
I am using Async Sockets and ThreadPool in order to accept data from a client at high speed. My code works flawlessly on my dev machine XP Pro, and also my Win2K Server test box. However it does not work on the server where it will be running. I have tracked the problem to the function being passed into QueueUserWorkItem not being called.
Has anyone ever come across this or have any idea what might be happening?
Thanks in advance
Andy
Windows 98 (win-doze): a 32 bit Extension to a 16 bit Graphical Shell of an 8 bit Operating System originally coded for a 4 bit Processor by a 2 bit company that can't stand one bit of competition.
|
|
|
|
|
are you running your application from inside your visualstudio IDE ?
try to start from the .net command prompt.
the application i'm writing at the moment (also dealing with sockets and threads) also misbehaves when i start it from inside visualstudio.
don't know why.
andi
|
|
|
|
|
What do you mean by "the function being passed into QueueUserWorkItem not being called"? The program hangs or it "skips" the call, as if it was not made?
If it's the case of hanging, don't forget that the ThreadPool have a limit of 25 threads per processor.
I hope that you have money because it’s necessary to be practical.
And I hope that at least once a year you put some money in front of you and say "you are mine" just to make clear who owns who. - Victor Hugo
|
|
|
|
|
It's ok guys, thanks for the replies. I found out what was happening. Basically a dll that contains a data holding class was apparently the wrong version which I discovered indirectly. Without this other app I would never have discovered the problem due to something catching uncaught exceptions in a C# Windows Service. Here's another one though, does anyone know why uncaught exceptions from a service do get caught somewhere and not logged?
Thanks again guys
Andy
Windows 98 (win-doze): a 32 bit Extension to a 16 bit Graphical Shell of an 8 bit Operating System originally coded for a 4 bit Processor by a 2 bit company that can't stand one bit of competition.
|
|
|
|
|
Hi,
I am trying to build a html in my c# project, which is used for show different tables or joint tables in the database. I don't know how to do that. Can anyone help me?
Thanks in advance!
|
|
|
|
|
I load my default mail clien(Outlook express).I want to put some files in attachment field(Runtime).I cann't understand where is reference to these files.
Process p = new Process();
string toemail = "somebody@server.com";
p.StartInfo = new ProcessStartInfo(@"mailto:"+toemail);
p.StartInfo.UseShellExecute = true;
p.Start();
|
|
|
|
|
Hi there:
I've faced with a silly bug in Menu , I dont know if u had it or not, but I'll be thankful if could help me!
The problem is when u set ur menu Left to Right, & WindowState to Maximized every thing changed!
I mean when menu is Left to Right & windows should start in Maximized mode! even when its normal & the shortcut seted to Maximized!!!
I dont know how I can describe it, so please try it once & look what happend?!
Any help is appreciated!
Always,
Hovik Melkomian.
|
|
|
|
|
Hi,i try to hold a number arraylists in a single main arraylist.But i think because of a referance problem, everytime i add a new arraylist, previous added lists became same with last added one;all items shown as the last arraylist's items.is anyone knows the solution or a different way to hold arraylists?
Thanks
|
|
|
|
|
Array is an object. You are trying something like:
ArrayList a1,a2;
a1=new ArrayList();
a2=new ArrayList();
...
a1.Add(a2);
...
a1.Add(a2); // thesame array
should be:
ArrayList a1,a2;
a1=new ArrayList();
a2=new ArrayList();
...
a1.Add(a2);
a2=new ArrayList();
...
a1.Add(a2); // another array
Hi,
AW
|
|
|
|
|
Thanks but a have already use this.maybe it would be more clear if i send my code
private ArrayList ALMainList=new ArrayList();
private ArrayList ALSendedList;
...
MyArrayList.Add("al1");
CatchSendedList(MyArrayList)
...
MyArrayList.Add("al2");
CatchSendedList(MyArrayList)
...
MyArrayList.Add("al3");
CatchSendedList(MyArrayList)
...
public void CatchSendedList(ArrayList ALSendedL)
{
ALSendedList=new ArrayList();
ALSendedList=ALSendedL;
ALMainList.Add(ALSendedList);
}
when i use this code i take the result:
ALMainList-item0 -> al3
ALMainList-item1 -> al3
ALMainList-item2 -> al3
|
|
|
|
|
You're just copying references around. When you write
ALSendedList=ALSendedL;
you're merely copying the reference to the array list, you are not copying the array list itself. You need to think about copying the items in the array list instead.
Cheers, Julian
Program Manager, C#
This posting is provided "AS IS" with no warranties, and confers no rights.
|
|
|
|
|
... or use CopyTo() method (not Clone())
Hi,
AW
|
|
|
|
|
.NET security sample anyone? There's a good/short article from Code Project by "Manuel Permuy": http://www.codeproject.com/csharp/cryptography.asp
The sample illustrates how to encrypt/decrypt/retrieve certs using WSDK.
QUESTION: I can do all this without WSDK - using just System.Cryptography? I'm new to this and I am looking for nice/short .NET examples (otherwise, i'd be reading MSDN):
1. sign/hash/encrypt data
- both PPK and classic symmetric algo (DES for example).
2. Also want to know how to "publish" your public key so receiver decrypt payload and verify signature (in your sample, client and receiver on same machine/process.) So, am I talking about exporting key/key blob? A handle to a key is meaningless on a remote machine.
3. retrieve certificates from cert stores (covered in this article)
4. add cert (makecert.exe or MMC/3rd party: I'm alrite with this.)
Any good articles? I want to do this all .NET - but as you mentioned, you don't get .NET support in dealing with cert stores. Is that still true?
Thanks.
norm
|
|
|
|
|
I try to send mail to the oher server ,but I cann't send it.Every time when I try, I have this kind of exception: Could not access 'CDO.Message' object.
I am sure that I had installed and runing SMTP service and CDO.
MailMessage mailMessage = null;
MailAttachment mailAttachment = null;
//GetMessageInfo(mailMessage);
mailMessage = new MailMessage();
mailMessage.From = textBoxFrom.Text;
mailMessage.To = textBoxTo.Text;
mailMessage.Subject = textBoxSubject.Text;
mailMessage.Body = textBoxMessage.Text;
//GetMessageAttachment(mailAttachment,mailMessage);
if(textBoxAttachment.Text != "")
{
if(File.Exists(textBoxAttachment.Text))
{
mailAttachment = new MailAttachment(textBoxAttachment.Text, MailEncoding.Base64);
mailMessage.Attachments.Add(mailAttachment);
}
else
{
MessageBox.Show("The file do not exist");
}
}
SmtpMail.SmtpServer.Insert(0,"mail.yahoo.com");
SmtpMail.SmtpServer = "mail.yahoo.com";
mailMessage.BodyFormat = MailFormat.Text;
SmtpMail.Send(mailMessage);
MessageBox.Show("Done");
|
|
|
|