|
You could try measuring the TimeSpans...
Then you can see what actually takes so much time...
I've found a living worth working for, but I haven't found work worth living for.
<marquee>
|
|
|
|
|
I have a DLL written in C++ (VS6) that has some interfaces in it.
I want to implement these interfaces in C#.
how do I create a class in C# that derives from a class in C++ that is in a DLL ?
|
|
|
|
|
How do you mean, interfaces ? C++ does not support interfaces in the C# sense.
You NEED to derive from the class directly, not just reuse the same method names ? Then you need to rewrite the class using C++/CLI ( that is, VC++ 2005 ). VS6 is not going to give you any joy here - you can call VC6 COM objects in C#, but you're going to see an interface only, no classes you could hope to derive from.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
VS2005 Express Edition:
I made a little class with an ManagementEventWatcher object (called myManagementEventWatcher) inside as an private member.
All works fine till I close my application (which uses my little class) and I receive an System.Runtime.InteropServices.InvalidComObjectException. The exception helper says:
COM object that has been separated from its underlying RCW cannot be used.
May be It's cause is that I placed myManagementEventWatcher.Stop() in the destructor of mij little class? But honeslty I don't really know wherelse te place that line of code?
Can someone help me please? Or give me some advice?
Thanks a lot!
|
|
|
|
|
Hello
thunderbirdje wrote: May be It's cause is that I placed myManagementEventWatcher.Stop() in the destructor of mij little class?
In C# there are no destructors. Instead there is a method called Dispose() . Put your Stop() in the If(Disposing) statement of the dispose() method. This should work!
Regards
|
|
|
|
|
If I'm thinking right. I should inherit from the class IDisposible and call the method Dispose() explicit?
Everything works fine now, but I am wondering. Is there maybe an other way instead of calling the Dispose() method explicit from the event Form1_FormClosing ?
I'd love to learn more
Thanks for the answer, Nader Elshehabi!
|
|
|
|
|
Hello
thunderbirdje wrote: I should inherit from the class IDisposible
IDisposable is not a class. It's an interface and you implement it, not inherit from it.
Your form already implements this interface for you, you only have to implement it in classes you write from the scratch. I understood from your post that the ManagementEventWatcher object is in your form. If so just double click on the class file name "*.cs" in your solution explorer to expand it. Then right click on "FormName.Designer.Cs" and view its code. Here you will find you Dispose() method. You don't call it explicitly.
If you still can't find it. View your class using the class explorer, select it, then right click on the Dispose() method name in the members pane, and view the declaration.
Regards
|
|
|
|
|
Hi
Nader Elshehabi wrote: IDisposable is not a class. It's an interface and you implement it, not inherit from it.
Indeed, I am still stuck in C++ terms
I found the Dispose() method. Actually my ManagementEventWatcher is in an object (instance of my little class) who is in term an object of my form.
My little class is a class build from scratch, but like you told me, I implemented the interface IDisposable and everyting works fine now!
Thanks a lot!
|
|
|
|
|
How can I catch a system key in a Form. I tried handling KeyPress, but it only works for regular keys, not for F1, F2 etc.
thanx
|
|
|
|
|
Nevermind, I foud it, I have to handle KeyDown.
|
|
|
|
|
i want to open any file by defalut program
as file test.doc
when i click on the button it will open MS word with this file ...
Palestine
|
|
|
|
|
I'm not sure I quite understand your question, but here it is:
if you need to start a process from your .Net application use System.Diagnostics.Process.Start
(string,string). So for a .doc file you would write:
System.Diagnostics.Process.Start("Word.exe","myFile.doc");
hope this helps
|
|
|
|
|
|
To open with the default program, without having to know what it is, use Process.Start("my.doc")
That will find word and use it. If the filename was an mp3, it would find the default media player, etc.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi,
I am trying to install VS.NET 2003, and i am getting following error:
[08/20/06,09:46:42] setup.exe: [2] ISetupComponent::Pre/Post/Install() failed in ISetupManager::InstallManagerHelper()
[08/20/06,09:46:42] setup.exe: [2] Component error string not specified in ISetupManager::AddToActionResultCollection()
Anyone have idea how to resolve this?
Thanks,
Shafik
|
|
|
|
|
Hello
Maybe the problem is in your copy or something?!! Try installing it on another machine.
Regards
|
|
|
|
|
I tried to install it again, it worked fine.
Thanks.
|
|
|
|
|
Hi i have the following problem executing this code:
if(BrowseOpera2.PostedFile != null)
{
HttpPostedFile opera2 = BrowseOpera2.PostedFile;
if(opera2.ContentLength > 0)
{
if (System.IO.Path.GetExtension(opera2.FileName).ToLower() != ".jpg")
{
return null;
}
string strFileName1 = Path.GetFileName(BrowseOpera2.PostedFile.FileName);
/* Save the file on the server */
BrowseOpera2.PostedFile.SaveAs(Server.MapPath(strFileName1));
/* Create the email attachment with the uploaded file */
MailAttachment attach = new MailAttachment(Server.MapPath(strFileName1));
/* Attach the newly created email attachment */
retVal.Attachments.Add(attach);
/* Store the attach filename so we can delete it later */
attach2 = strFileName1;
}
else
{
return null;
}
}
else
{
return null;
}
Exception rised executing :
BrowseOpera2.PostedFile.SaveAs(Server.MapPath(strFileName1));
the exception is ACCESS DENIED, but on the IIS settings i both writing and reading are allowed
can someone help me please?
Marco
|
|
|
|
|
You have to allow write access to the user account that is used to run the ASP.NET code. This is usually the ASPNET or the IIS_WPG account.
---
b { font-weight: normal; }
|
|
|
|
|
But when i use the code above just to upload images to the server, everything is ok. only in this case i have exceptions...and of course i don't know why...it is taken from a copy & paste from another file i wrote. And of course everything works on the old file but i can't find the bug here...
|
|
|
|
|
You are storing the file at the same location on the server that it had on the client computer. This is very bad. It means:
:: Anyone can attempt to store a file anywhere on the server! Huge security hole!
:: The directory structure have to be the same on the server as on the client, or it doesn't work.
:: The ASP.NET user account has to have write access to the folder, or it won't work. As it can be any folder, you would have to grant write access to every folder, and that would only serve to widen the security hole.
---
b { font-weight: normal; }
|
|
|
|
|
Hi,
I have a C# project which imports a .csv file, however some of the characters in the file are square characters. These characters mean that when I write the output to a text file I get a newline where the square characters were. My question is how can I remove these square characters? If I wanted to remove say the character value "s" I could write:
String holder = "susan";
char[] myChar = {'s'};
String newString = holder.Trim(myChar);
Output = "uan"
The problem is I don't know how to remove the square character because it is not a conventional ASCII character.
Any help is much appreciated.
Thanks
James
|
|
|
|
|
Not clear for me what you actually try to do, but hope short info will lead you to the solution.
Unix environments use "\n" for newline, while Windows uses combination "\r\n".
While in C you can use "\n" to indicate newline for both Unix & Windows environments,
in c# you should specify explicitly what you want that is "\r\n" for Windows, and even better you should use Environment.NewLine
SO, my guess is your CVS file is from Unix like environment so you should replace single "\n"s with "\r\n" OR you should correct the code which generates .CVS file to use correct new line value.
Vitaliy Tsvayer
Tikle
|
|
|
|
|
Hello
How did you display your CSV file to view the square char?? Using the notepad maybe?
James19841984 wrote: The problem is I don't know how to remove the square character because it is not a conventional ASCII character.
AFAIK it should have a code no matter what!! Try reading a known file char by char until you reach this char's position, then display its code in a messagebox or something.
Another thing, open a CSV file with an editor -eg notepad-, copy the square char -if you know that ALL squares are the same char. Sometimes the notepade jst display a square for several chars that it doesn't understand. When you copy the char, paste it into your code -ie. hardcode it-
Also use:
char Sq;
While(MyString.IndexOf(Sq) != -1)
MyString.Remove(MyString.IndexOf(Sq), 1);
Regards
|
|
|
|
|
Hi,
i also faced same problem some days back.
but i found the ans.
you can use '\r\n' for that newline character.
here is the example
string strTemp="Store Your String Here!";
strTemp.Replace("\r\n","");
hope this works.
Nitin...
|
|
|
|