|
1. C# to unmanaged: you have at most three choices:
a. Use interop code (PInvoke) to call functions in the unmanaged dll. Search this site and Google for Pinvoke should get you some examples. This can be tricky, since you must pay attention to things like pointers, and explicitly "pin" things that might be referenced from the unmanged code, so the GC doesn't move them.
b. If the unmanaged dll happens to be a COM dll, you can use TlbImp tocreate a wrapper dll that will handle the managed-unmanaged buisness for you.
c. Write a managed C++ wrapper that exposes the unmanaged dll's methods as managed versions, and handles data conversions for you.
2. Unamanaged to C#. C# dlls are already COM objects, you just need to specify "register for COM" in the project settings (or use the Regasm utility to register the C# dll (use the /tlb option so it creates a type library file for you). It will need to have a strong name key, and should be installed to the GAC. You can the use normal C++ methods to deal with the C# dll as a COM component.
(use #import to import the type library and create interface wrapper methods for you)
Absolute faith corrupts as absolutely as absolute power
Eric Hoffer
All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke
|
|
|
|
|
I have a application with a datagrid...
Works fine but i want to remove the "add a new line row", the one starting with * at the left side.
I removed it with datagrid1.ReadOnly = false, but the i cant edit the fields already in the datagrid...
How can i solve this problem?
//Johan
|
|
|
|
|
I'd like to make my C# implment the IDownloadManager COM component for IE to handle certain types of files.
Here's an MSDN article on the process, but it's for C++.
http://support.microsoft.com/default.aspx?scid=kb;en-us;327865
Anyone ever develop this component in C#? If so, can you paste the code for your interface?
Thanks,
Tim
|
|
|
|
|
I have service that is installed in several workstations. The service uses the same port number.
I would like to create an application that detects how many workstations have the service installed in the subnet.
Maybe by detecting the listening port or by the service name.
Any help will be greatly appreciated
|
|
|
|
|
Hi there,
IMO, I'd detect the installed service by the listening port. Just simply create a connection to the remote machine on that port. if it's successful, that means the service is installed there
<< >>
|
|
|
|
|
When attempting to run a 1.1 based exe on 2.0, you get an ugly TypeInitialization exception.
I have yet to attempt running 2.0 on 1.1 machine.
Either way, assuming the app does not have access to it's native framework, does anyone know a good way to display a user-friendly message explaining the problem?
|
|
|
|
|
If it's possible, you're probably better off checking for the framework before the application is installed, and letting the user install it before proceeding further. That's what we do and it works pretty good since our installer is not .NET based. I suspect you are in the same situation.
Innosetup[^] is a great free installation tool.
Carl Mercier
Geek entrepreneurs, visit my blog! [^]
|
|
|
|
|
Thanks Carl, I'll check it out...
|
|
|
|
|
Tom Ollar wrote: When attempting to run a 1.1 based exe on 2.0, you get an ugly TypeInitialization exception.
I have not seen this problem. Did you apply the .NET 2.0 element stuff in the App.config file? I have ran my rather complex application without issues on both runtime, binary serialization is even forwards and backwards compatible
xacc-ide 0.0.99-preview7 now with C#, C, C++, IL, XML, Nemerle, IronPython, Perl, Caml, SML, Ruby, Flex, Yacc, Java, Javascript, Lua, Prolog and Boo highlighting support!
|
|
|
|
|
The app is the MiniWalker.
The current version was compiled with VS 2003 and it only runs with the 1.1 Framework. On a machine with only the 2.0 Framework installed, it crashes with the Type Initialization error.
Microsoft says this is correct here.
So it looks like a real setup program is the only answer...
-- modified at 10:20 Saturday 5th November, 2005
|
|
|
|
|
Hello All, Not sure where to post this.
I'm looking for advice on the following. Within Excel, I'd like to have the ability to pass some parameter and get back an image corresponding to that parameter. For example, imagine you pass in "MSFT" and "1yr" and get back a stock trend image. Ideally, I'd be passing in an array of values, and for each image, I'll place it on the adjacent cell of the selected value.
The image is created using a Java tool sitting on a separate server. The tool grabs some data from a db using the parameter passed in and then generates the image accordingly. I can wrap that up as a web service.
I could then consume this service in Excel and get the image for each value passed and place it as a bitmap in a cell in Excel.
Does anyone have advice or can point me to a solution or sample that already exists for this?
I don't really have to do it C# or .NET at all for that matter, but it certainly would be ideal.
I have Office 2003.
Thanks
Julian
|
|
|
|
|
hi,
I am doing a project in C# winform.
When I run the app, I want to display the form in the entire screen (even the taskbar and the status bar should not be shown). The app should take over the entire screen.
How do I do this??
Thanks.
|
|
|
|
|
Set these 3 properties or do it in the designer.
this.MaximizeBox = false;
this.TopMost = true;
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
|
|
|
|
|
Thanks!!!!
|
|
|
|
|
|
Hello!
I have a big problem...
I'm working with a richTextBox and I need to know how every characters is painted..I dont know if you understand!
The problem is the following:
i have a string in a richTextBox and i can color every characters of it by a different way. Depending by the color, i must put a prefix in front of each char...
Any suggestion..?
Thank You
Enrico
|
|
|
|
|
The easiest way is to use the SelectionColor[^] property. However, moving the Selection character by character doesn't seem to be a great idea.
You can also try getting the Rtf[^] property and then parsing it to figure out the colors. You can find the RTF Spec here[^].
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
I would like to develop a control for a mapping program I have, but I don't even have a clue where to start. Any ideas?
Here is what I want the control for: My mapping program effectively reads a list of points with GPS locations and power values. I draw a circle on a map at the GPS point, and the color of the circle is one of four values, depending on the power. In other words, the possible power spectrum is divided with three threshold values into four bands. All of this already works fine.
Here is what I want the control to do: I want the user to have a graphical method of adjusting the power thresholds between the four power bands. I would like to show something like:
Color1 | Color2 | Color3 | Color4
where the ColorN are colored rectangles representing the four bands, each in that band's assigned color, and the vertical bars are splitters than can be moved back and forth with the mouse, representing the power thresholds between the bands.
Any thoughts would be welcome. Thanks.
|
|
|
|
|
Hello,
I need to do following. If object was not initialized then assign variable to it like code below.
Right now it throws an error becouse MyCert is not initialized when compared to null. How do I do what I need to do?
<br />
X509ChainElement MyCert;<br />
foreach (X509ChainElement cert in chain.ChainElements)<br />
{<br />
if ( MyCert == null)<br />
{<br />
MyCert = (X509ChainElement) cert;<br />
continue;<br />
}<br />
else<br />
{<br />
.....;<br />
}<br />
}<br />
<br />
|
|
|
|
|
artisticcheese wrote: Hello,
I need to do following. If object was not initialized then assign variable to it like code below.
Right now it throws an error becouse MyCert is not initialized when compared to null. How do I do what I need to do?
X509ChainElement MyCert;
foreach (X509ChainElement cert in chain.ChainElements)
{
if ( MyCert == null)
{
MyCert = (X509ChainElement) cert;
continue;
}
else
{
.....;
}
}
The quickest way is to initialize your object at the beginning. I am assuming you will be doing some processing between your declaration and your foreach loop, otherwise it makes no sense to check for a null because you know it is uninitialized. So it would look like this:
X509ChainElement MyCert = null;
// do some processing and other things.....
foreach (X509ChainElement cert in chain.ChainElements)
{
if ( MyCert == null) //has not been initialized somewhere before the loop
{
MyCert = (X509ChainElement) cert;
continue;
}
else
{
.....;
}
}
But what I don't understand about your code is that only the first element will ever be assigned to MyCert. Of course I only get to see a small snippet and this may be the functionality you want.
|
|
|
|
|
Hello,
I am loading a file within my app and the way I am refering to it is something like that:
<br />
this.richTextBox1.LoadFile("c:\\tmp\\Document.rtf");
However if I want to deploy the application on some other machine, obviously the file will not be there. So, if I want to include the file in my application how do I refer to the file then?
Thank you.
|
|
|
|
|
Just put it in your application'S folder and do a this.richTextBox1.LoadFile("Document.rtf");
You might also insert the file as a resource
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi,
I am using : Help.ShowHelp (this, "Help\\EconomicAssessmentHelp.chm");
whre Help is the folder in my application folder (the one that contains the solution and all the clasees, forms, etc...). But the statement above still does not work, unless I provide the whole path.
Which is "C:\\MyDocuments\.... etc.
Any ideas why it does not work?
Thank you
|
|
|
|
|
zaboboa wrote: Hello,
I am loading a file within my app and the way I am refering to it is something like that:
this.richTextBox1.LoadFile("c:\\tmp\\Document.rtf");
However if I want to deploy the application on some other machine, obviously the file will not be there. So, if I want to include the file in my application how do I refer to the file then?
Thank you.
Is the file something you will deploy with your code? If so you will know where it should be. You could try something like this:
try
{
this.richTextBox1.LoadFile("c:\\tmp\\Document.rtf");
}
catch
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Title = "Please locate Document.rtf";
ofd.Filter = "RTF File|*.rft";
ofd.ShowDialog();
if ( ofd.FileName != "" ) { this.richTextBox1.LoadFile( ofd.FileName ); }
else {
}
|
|
|
|
|
You could put the .rtf file in the same directory as the .exe. You can access the startup path with:
AppDomain.CurrentDomain.SetupInfo.ApplicationBase
The application base is ALWAYS the location of the .exe, NOT the location you started the .exe from.
|
|
|
|