|
Replace :
System.Windows.Forms.UserControl
with :
System.Windows.Forms.ContainerControl
|
|
|
|
|
Hello,
How can i get a bit of C# code to launch an external program (for instance notepad) ?
Regards,
Tariq
|
|
|
|
|
System.Diagnostics.Process.Start ("notepad.exe");
Check out the documentation on the System.Diagnostics.Process class for more info...
Andreas Philipson
|
|
|
|
|
Thanks for the information. Appreciate it
But I still have one doubt. That is, how do i pass parameters to the application I am trying to run.
eg . notepad test1.txt
I tried giving it in the file name - but that doesnt work.
I couldnt find any other relevant property to achieve this.
Can you help?
Regards,
Tariq
|
|
|
|
|
using System.Diagnostics;
ProcessStartInfo notepad = new ProcessStartInfo ("notepad.exe", "C:\\SomeFile.txt");
Process.Start (notepad);
Andreas Philipson
|
|
|
|
|
Hi,
Has anyone tried using the Process.GetProcesses(string machinename) overload of the Process class in the System.Diagnostics? I am using VS.NET beta 1. I am badly in need of viewing (just viewing!!!) the processes running on a different machine on the same domain.
Can someone help me please?
Thanks.
|
|
|
|
|
As everyone probably knows, in C# (and probably other .NET languages), you can put comments at the top of any class or function in this format (this example is for a function):
void MyFunction(string thing)
The great thing is that C# will automatically use these comments when doing tooltips for auto-complete. I love that.
Unfortunately, it seems that auto-complete does not correctly deal with < and > characters when they appear in the XML. For example, if the following XML appears above a function:
...then that is exactly how auto-complete will display the description of the function. It should be doing standard "entity" conversion, e.g. converting < to < and > to > and so on. (You can't just put < into the summary itself, because that's not legal in XML. Try it -- you'll get an error message in the auto-complete tooltip.)
For another example of this, try typing "Directory.GetLogicalDrives(" into a C# file, and observe that the tooltip that comes up says:
Retrieves the names of the logical drives on this computer
in the form "<driver letter>:\".
Oops. Microsoft, please fix the tooltip code?
By the way, Visual Studio's utility for creating HTML documentation (Tools menu, "Build Comment Web Pages..." command) DOES correctly deal with < and > in the XML.
Mike Morearty
mike@morearty.com
http://www.morearty.com
|
|
|
|
|
I might have the wrong end of the stick here but I remember back when I first looked into XML that you had to define the "data type" of the XML entity for odd characters and entity-conversion to display properly.
Unfortuanatley I am not near my XML book or VS.NET so I cannot remember how to do it, but if you know what I mean then see if defining that data type will help. Not the best solution but it might work
regards,
Paul Watson
Bluegrass
Cape Town, South Africa
Do you Sonork? I do! 100.9903 Stormfront
"The greatest thing you will ever learn is to love, and be loved in return" - Moulin Rouge
|
|
|
|
|
Hai,
I was testing the following code... But i get an error saying...
"The type or namespace name 'EventLog' does not exist in the class or namespace 'WriteToAnEventLog_csharp'."
Why is this so? What part am I missing? I am not using VS.NET Beta. I am using notepad to type this text and used, csc test.cs to compile the code.
Please help me....
using System;
using System.Diagnostics;
namespace WriteToAnEventLog_csharp
{
///
/// Summary description for Class1.
///
class Class1
{
static void Main(string[] args)
{
string sSource;
string sLog;
string sEvent;
sSource = "dotNET Sample App";
sLog = "Application";
sEvent = "Sample Event";
if (!EventLog.SourceExists(sSource))
EventLog.CreateEventSource(sSource,sLog);
EventLog.WriteEntry(sSource,sEvent);
EventLog.WriteEntry(sSource, sEvent, EventLogEntryType.Warning, 234);
}
}
}
Thanks.
|
|
|
|
|
What command line parameters are you using?
you have to use the /r:System.dll to get it to compile...
try this:
csc /target:winexe /out:eventlog.exe class1.cs /r:system.dll
Andreas Philipson
|
|
|
|
|
the /r:System.dll is done automatically when you say csc class1.cs. Also I tried the second option that you told. No luck. But I got VS.NET beta 1 installed on my machine. I created a c# project, built it and its just ducky.
Thanks anyways.
|
|
|
|
|
i init. the child window in instructor of main window.
but if i specified the parant of child to main window, it will rise a exception.
how to do? and where to load the show function?
The Internet Give a Chance to Learn. I Do!
|
|
|
|
|
I have built a simple C# Windows Application and it runs on the machine I built it on fine.
I put the .EXE on another machine and tried to run it there it failed. It needed mscoree.dll so I added that to the directory the .EXE is in. Now I'm getting a .NET frame work initialization error. I guess I need to install the .NET frame work (maybe?).
If that is the problem, how do I do that without installing the Visual Studio.NET?
Rick Crone
|
|
|
|
|
You need to have the .NET runtime installed on target machines [its a 18-19 MB download]
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
Nish is a BIG fan of Goran Ivanisevic
|
|
|
|
|
download this and install it on the target machine
http://download.microsoft.com/download/VisualStudioNET/Trial/2.0/W982KMeXP/EN-US/dotnetfx.exe
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
Nish is a BIG fan of Goran Ivanisevic
|
|
|
|
|
Rick you need to install the .NET framework on the target machine. Developing for .NET brings along awhole slew of new things, including runtime baggage.
If you got VS.NET via an MSDN subscription then you should also have got a CD with the entire .NET Framework on it. Use that on the target machine.
From what I have heard there will be a "service pack" for Windows XP (not sure about 2000, but probably as well) that will include the .NET Framework. This should be released once .NET has gone gold.
Future versions of Windows will have it all built in. I can't wait
regards,
Paul Watson
Bluegrass
Cape Town, South Africa
Do you Sonork? I do! 100.9903 Stormfront
"The greatest thing you will ever learn is to love, and be loved in return" - Moulin Rouge
|
|
|
|
|
|
I have the next DLL:
".h"
#ifdef BABMD5_EXPORTS
#define BABMD5_API __declspec(dllexport)
#else
#define BABMD5_API __declspec(dllimport)
#endif
// This class is exported from the BabMD5.dll
class BABMD5_API CBabMD5 {
public:
CBabMD5(void);
};
BABMD5_API long WINAPI EncodeText(LPCTSTR p_sPlainText, LPTSTR p_sEncodedText, long nBufferLen);
".cpp"
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
BABMD5_API long WINAPI EncodeText(LPCTSTR p_sPlainText,LPTSTR p_sEncodedText, long nBufferLen)
{
CMD5 m_md5;
// Here get the user name always in uppercase,
// and if we've got a NULL pointer then we fill it with an empty string
// We've done this way because of Visual Basic null strings
if(p_sPlainText!=NULL)
m_md5.setPlainText( _strupr((LPTSTR)p_sPlainText) );
else
m_md5.setPlainText("");
if (nBufferLen>32)
// and return the encoded string also un uppercase
strcpy(p_sEncodedText,_strupr((LPTSTR)m_md5.getMD5Digest()));
return 33;
}
// This is the constructor of a class that has been exported.
// see BabMD5.h for the class definition
CBabMD5::CBabMD5()
{
return;
}
I need call the function "EncodeText" from C# to do it I typed the next code:
[DllImport("BabMD5.dll")] static extern long EncodeText(
string p_password,
[MarshalAs(UnmanagedType.LPTStr)]string p_encText,
long p_size);
...
try {
string sText = "";
EncodeText("testestest",sText,33);
} catch(DllNotFoundException exc) {
Console.WriteLine(exc.ToString());
} catch(EntryPointNotFoundException exc) {
Console.WriteLine(exc.ToString());
}
But I doesn't return nothing. Anybody know what's happen?
Thank you.
|
|
|
|
|
Please read the article:
http://www.codeproject.com/csharp/unmanage.asp
your problem will be done.
The Internet Give a Chance to Learn. I Do!
|
|
|
|
|
The first thing that I've made was read the article, It's a good article where I found how to avoid the problem of load the dll and the method but my actual problem is that I can load and detect the method but this don't return nothing. I don't know what it's happening.
|
|
|
|
|
If you want to return 'sText', you must ref the var.
Try this:
[DllImport("BabMD5.dll")] static extern long EncodeText(
string p_password,
ref string p_encText,
long p_size);
EncodeText("testestest",ref sText,33);
The Internet Give a Chance to Learn. I Do!
|
|
|
|
|
Good day. How do I send and receive WM_COPYDATA messages in C# that contain data? In particular, how do I unpack the COPYDATASTRUCT in C# when I get the WM_COPYDATA message? Sample code would be appreciated. Thanks Robert
|
|
|
|
|
I have a C# application, where I use a good old COM Object written in VC6. This is the easy part...
The COM Object implements Connection Points, to throw events to the client using it.
I can not get C# to catch those events. I have tried everything I can find in the documentation, but it don't work, the event-functions in C# is never called.
Anybody have a small sample of how to do this?
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
I have an exe-file and some .NET components (.dll) that the exe file uses. But when I try to start the exe file, I get the following error message. Does anybody know what to do here? Thanx,
ds
error message:
"class not registered."
========== Exception Text ==========
System.Runtime.InteropServices.COMException (0x80040154): class not registered
at System.Windows.Forms.AxHost.CreateInstance()
at System.Windows.Forms.AxHost.GetOcxCreate()
at System.Windows.Forms.AxHost.TransitionUpTo(Int32 state)
at System.Windows.Forms.AxHost.CreateHandle()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.AxHost.EndInit()
at VMS.ITFieldEditor.VDlgITFE.InitializeComponent()
at VMS.ITFieldEditor.VDlgITFE..ctor()
at VMS.ITFieldEditor.VITFieldEditor..ctor()
at VMS.ITFEBridge.VITFEBridge..ctor()
at TestDotnetApp.MainWin.btnStart_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
========== Loaded Assemblies ==========
mscorlib
Assembly Version: 1.0.2411.0
Win32 Version: 1.0.2914.16
CodeBase: file:///c:/windows/microsoft.net/framework/v1.0.2914/mscorlib.dll
----------------------------------------
TestDotnetApp
Assembly Version: 8.0.0.0
Win32 Version: 8.0.0.0
CodeBase: ...
----------------------------------------
System
Assembly Version: 1.0.2411.0
Win32 Version: 1.0.2914.16
CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v1.0.2914/System.dll
----------------------------------------
System.Drawing
Assembly Version: 1.0.2411.0
Win32 Version: 1.0.2914.16
CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v1.0.2914/System.Drawing.dll
----------------------------------------
System.Windows.Forms
Assembly Version: 1.0.2411.0
Win32 Version: 1.0.2914.16
CodeBase: file:///C:/WINDOWS/assembly/GAC/System.Windows.Forms/1.0.2411.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
ITFEBridge
Assembly Version: 8.0.0.0
Win32 Version: 8.0.0.0
CodeBase: ...
----------------------------------------
TestDotnetApp.resources
Assembly Version: 8.0.0.0
Win32 Version: 8.0.0.0
CodeBase:...
----------------------------------------
ITFieldEditor
Assembly Version: 8.0.0.0
Win32 Version: 8.0.0.0
CodeBase:...
----------------------------------------
CBase
Assembly Version: 8.0.0.0
Win32 Version: 8.0.0.0
CodeBase: ...
----------------------------------------
CFieldEditor
Assembly Version: 8.0.0.0
Win32 Version: 8.0.0.0
CodeBase: ...
----------------------------------------
CImageViewer
Assembly Version: 8.0.0.0
Win32 Version: 8.0.0.0
CodeBase: ...
----------------------------------------
AxCCOREVIEWERLib
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: ...
----------------------------------------
CCOREVIEWERLib
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: ....
----------------------------------------
CUIBase
Assembly Version: 1.0.657.22684
Win32 Version: 1.0.657.22684
CodeBase: ...
----------------------------------------
CVisUtils
Assembly Version: 8.0.0.0
Win32 Version: 8.0.0.0
CodeBase:...
----------------------------------------
ITFieldEditor.resources
Assembly Version: 8.0.0.0
Win32 Version: 8.0.0.0
CodeBase: ...
----------------------------------------
|
|
|
|
|
Did you register your dll?
Read this page..
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpapndx/html/_cor_deployment_and_configuration.asp
update: also this link.. depending on what you're doing..
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cptools/html/cpgrfassemblyregistrationtoolregasmexe.asp
|
|
|
|