|
|
At my last company after writing over 100,000 lines of test and prototype code in .NET, I recommended we switch back to C++/MFC. C# was nice, I loved working in it, but for what we were doing, I felt it just isn't ready for "thick" client apps.
You will have to rewrite, and would want to anyway in order to optimize the app for Win32 CE, but it's not difficult.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Joe Woodbury wrote: I loved working in it, but for what we were doing, I felt it just isn't ready for "thick" client apps.
Can you elaborate. I'm always interested to know where others have hit problems with writing thick clients with C#, so that I can avoid the same pitfalls.
thanks,
Michael
CP Blog [^] Development Blog [^]
|
|
|
|
|
How can i tell if a remote pc is connected to the network using c#.
-- modified at 10:23 Thursday 16th February, 2006
|
|
|
|
|
you could ping it via c# and see if you get a reply. You could enumerate the network and get a list of all the machines names.
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Hi,
thanks for the response. i have tried to ping using c# but this takes too long. what i am trying to do is get all of the machines in the active directory on my network and then check to see if each one is connected. i then load a listview item into a listview with the relevant image. this is for a network admin tool.
Thanks again for any help on this.
|
|
|
|
|
Hi!
I´m currently programming a GUI for a Command-Line-Based System. The administration is done with a command-line-Admin-Tool similar to Windows´ CMD-Dos-Box.
Unfortunately i cannot run the admin-commands on their own, because the only run in this cmd-line-based gui, which seems to be an stand-alone interpreter, not a dos-box running seperate programs...
Also there is no API available i could use.
What i´d like to do is to call a DOS-Box/Admin-Tool via the Process-Object and send my commands to it via the StandardInput-Object.
Sending works fine, but when I do the reading from StandardOutput-Stream, i cannot find an end-mark for my while-Statement.
(For testing-purposes i send everything to the system-console in order to see, what comes back from my process)
string sto = null;<br />
string ste = null;<br />
while ( ((sto = process.StandardOutput.ReadLine()) != null) || ((ste = process.StandardError.ReadLine()) != null) )<br />
{<br />
if (sto != null)<br />
System.Console.WriteLine(sto);<br />
if (ste != null)<br />
System.Console.WriteLine(ste);<br />
sto = null;<br />
ste = null;<br />
}
When the command has finished, the loop hangs in the ReadLine-Statements.
Peeking into the stream doesn´t work and hangs also...
How could i do this?
Thanks a lot!
J.
-- modified at 9:43 Thursday 16th February, 2006
|
|
|
|
|
Hello,
I am currently looking at using the System.DirectoryServices namespace to access data on a 3rd party LDAP server (not Active Directory).
After reading up and putting together a few test applications, I should be honest and state that I havent got very far at all.
Can anybody answer or point in the right direction for these questions?:
- Does .NET 1.1 DirectoryServices support connecting to a LDAP server that requires me to present a client certificate?
- If so, how do I specifcy which certificate to use? Or does it use the OS certificate store?
- If .NET 1.1 doesnt support this, does .NET 2.0?
Although I would prefer to stay within the realms of the .NET namesapce, DirectoryServices may not be the right way to go on this. If this is the case can anybody recommend a Win32 based LDAP API that does support this functionality?
|
|
|
|
|
I'm trying to populate an empty SQL Server database with DataSet, which is filled from XML file, but when I execute SqlDataAdaptor::Update() I get exception:
Update unable to find TableMapping['Table'] or DataTable 'Table'
Is it possible to Update such empty database, and what I am missing to execute method corectly?
the code is:
string strConnection;<br />
strConnection = "Data Source=SQLServer;Initial Catalog=DB1;Integrated Security=SSPI;"<br />
<br />
SqlConnection objConn = new SqlConnection(strConnection);<br />
objConn.Open();<br />
<br />
DataSet dbSet = new DataSet("myDataSet");<br />
dbSet.ReadXmlSchema("c:\\XML\\Data.xsd");<br />
dbSet.EnforceConstraints = false;<br />
dbSet.ReadXml("c:\\XML\\Data.xml");<br />
<br />
SqlDataAdapter DataAdaptor = new SqlDataAdapter("",objConn);<br />
DataAdaptor.SelectCommand.Connection = objConn;<br />
DataAdaptor.MissingMappingAction = System.Data.MissingMappingAction.Passthrough;<br />
DataAdaptor.MissingSchemaAction = System.Data.MissingSchemaAction.Add;<br />
<br />
DataAdaptor.Update(dbSet);<br />
...<br />
|
|
|
|
|
|
table 'Table' don't exist. No tables exist in the database. It's empty.
In such case is it possible the ::Update() method to create the database schema from DataSet?
|
|
|
|
|
Hi All i have a slight problem i can get information from WMI ti locate all disks of type 3 and 4. Which is great. Now the hard part how do i pass it to the html spinnerbox control i have. By the way this is media center application i am creating hence the need to use HTML as the gui.
thanks in advance
Dave
|
|
|
|
|
I've a list of panels one over the other and all inside another panel.
I want to scroll up, down these panels.
What is the correct way?
|
|
|
|
|
If assume you have a master panel called "panelMaster". Inside this, you have 10 sub panels "panel1", "panel2", ... "panel10". You can set "AutoScroll" to true for "panelMaster" and your app will display vertical scrollbars when panelMaster is not large enough to fit and display all of the subcontrols.
- Malhar
|
|
|
|
|
but i've 1000 or more panels inside, so how can i do?
|
|
|
|
|
I need this because i'm constantly leaving my USB thing in the computer, so the idea is, app runs when usb is inserted, if i log off and i've left my stick, logoff is paused/stoped, and i get a message telling me to remove it.
(this wouldn't be so bad if it was only my home computer)
|
|
|
|
|
Usually when a "stick" is connected to a pc, it has a drive letter assigned.
Test for that and then display your message. In XP the "shutdown -a" command will abort
a shutdown of the pc.
|
|
|
|
|
I have a requirement to use a dll written in Visual C++ 6.0 in my C# application. In order to establish the link between my application and the dll, I have written a ATL COM Component in Visual C++.NET [visual studio .NET version 8]. This COM component is referenced in my C# application. The COM component statically links with the 6.0 dll.
I am facing problems in passing data from C# to the dll through the COM component.
Description:
1. The dll exposes a function as:
__declspec(dllexport) int __stdcall ProblemFunction(int param1, BYTE param2, BYTE param3, BYTE *param4, DWORD *param5);
2. In the COM wrapper component, I have declared an interface method as:
[id(25), helpstring("method ProblemFunc")] HRESULT ProblemFunc([in] SHORT param1, [in] BYTE param2, [in] BYTE param3, [in, out] BYTE* param4, [in, out] LONG* param5, [out, retval] BYTE* param6);
where, param6 is used to return the value returned by dll function to the C# client application.
The implementation of this interface function is given below:
STDMETHODIMP
Wrapper::ProblemFunc(SHORT param1, BYTE param2, BYTE param3, BYTE* param4, LONG* param5, BYTE* param6)
{
*param6 = ProblemFunction(param1, param2, param3, param4, (DWORD*)param5);
return S_OK;
}
3. In the C# client application, I am calling the COM function as:
byte returnValue = DllWrapperObject.ProblemFunc(value1, (byte)value2, (byte)value3, ref value4, ref value5);
Here, I am facing problems passing value4 and value5 because:
a. For value4 I need to pass a structure.
b. For value5 I need to pass the size of the structure being passed in value4.
The structure to be passed is as required by the dll. The C++ structure is:
typedef struct
{
DWORD var1;
DWORD var2;
struct
{
DWORD var3;
char var4[16];
DWORD var5;
} var6[3];
} TEST_STRUCT;
I wrote the structure's equivalent in C# as a class as I had to create an array. The C# implementation of the above given structure is:
internal class InnerStruct
{
long var3;
char[] var4 = new char[16];
long var5;
internal static int GetSizeOfClass()
{
return (sizeof(long) + sizeof(char) * 16 + sizeof(long));
}
}
internal class TestStruct
{
long var1;
long var2;
InnerStruct[] var6 = new InnerStruct[3];
internal static int GetSizeOfClass()
{
return (sizeof(long) * 2 + InnerStruct.GetSizeOfClass() * 3);
}
}
Questions:
1. Is there any better way to define the structure equivalent in C#?
2. How can I get the size of the structure/class for passing it to the dll?
3. How to pass the handle of the structure/class object from C# to the dll so that it can fill it up and return it to the client app for future usage?
|
|
|
|
|
Ok,
You can define your C# structure like this:
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
internal struct InnerStruct
{
public int var3;
[MarshalAs(ByValTStr, SizeConst = 16)]
public string var4;
public int var5
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
internal struct TestStruct
{
public int var1;
public int var2;
public InnerStruct[3] var6;
}
2. uint structSize = Marshal.Sizeof( typeof( TestStruct ) );
3.
TestStruct ts = new TestStruct();
ProblemFunc( value1, value2, value3, ref ts, structSize );
Deus caritas est
|
|
|
|
|
Thanks for replying to the query, but the problems do not get fixed... I am still facing problems with the following:
1. I cannot define array of structures as mentioned:
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
internal struct TestStruct
{
public int var1;
public int var2;
public InnerStruct[3] var6;
}
when I compile the code, I get the error as:
Array size cannot be specified in a variable declaration (try initializing with a 'new' expression).
2. I cannot use the new operator inside structures, like this:
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
internal struct TestStruct
{
public int var1;
public int var2;
public InnerStruct[] var6 = new InnerStruct[3];
}
when I compile this code, I get the error as:
'TestStruct': cannot have instance field initializers in structs.
3. As I had mentioned earlier, the VC++ 6.0 dll expects a byte pointer. To call the ProblemFunction() from a code in VC++ 6.0, I will be passing the information as:
TestStruct testVar;
int size = sizeof(testVar);
ProblemFunction(value1, value2, value3, (BYTE *)&testVar, &size);
Now that I have written the wrapper on same lines, the ProblemFunc needs proper values. That means that I need to somehow pass TestStruct object defined in C# as a byte pointer to the COM function ProblemFunc()
Can you please help me out with this....
Regards,
Nataraj.
|
|
|
|
|
Ok, change your TestStruct to look like this
StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
internal struct TestStruct
{
public int var1;
public int var2;
[MarshalAs(UnmanagedType.LPArray, SizeConst = 3)]
public InnerStruct[] var6;
}
TestStruct ts = new TestStruct();
uint sizeStruct;
System.IntPtr p;
ts.var6 = new InnerStruct[3];
structSize = Marshal.Sizeof( typeof( TestStruct ) );
p = Marshal.AllocHGlobal( structSize );
Marshal.StructureToPtr( ts, p, true );
ProblemFunction(value1, value2, value3, p, structSize );
Marshal.FreeHGlobal( p );
Deus caritas est
|
|
|
|
|
|
|
hi,
Why this code has no effect?
RegistryKey regKey ;
string strServiceName = "";
regKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\NetworkCards\9");
strServiceName = regKey.GetValue("ServiceName").ToString();
regKey.Close();
regKey = Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentControlSet\\Services\\" + strServiceName + "\\Parameters\\Tcpip", true);
regKey.SetValue("IPAddress", Encoding.ASCII.GetBytes("10.1.1.1/0/0"));
regKey.Close();
|
|
|
|
|
This code will be hugely unreliable as this registry path "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\NetworkCards\9" will not exist on all PC's - mine inclusive.
When I do locate the info on my local machine, it is in ... \CurrentVersion\NetworkCards\2. Following the service name through to SYSTEM\CurrentControlSet\etc leads me to the IPAddress you are trying to set, but bad news - its set to 0.0.0.0 (probably because im on a company LAN - so all the dhcp settings etc are set instead)
Maybe go back to the drawing board and consider what it is you are actually trying to accomplish, and if there is another way to do so!
|
|
|
|
|