|
Well, I'm no expert here, but I can't recollect any specific resources as to deal with proxy/stub (in COM world).
You can refer to Don Box's Essential COM or Inside COM / DCOM for a thorough treatment on the subject.
In simpler terms Proxy might refer to a piece of code which helps to communicate between the provider / consumer.
I hope I'm not confusing you too much.
Cheers
Kannan
|
|
|
|
|
hi $iva,
You cannot add reference to the dll (assembly) you have created in .net 'cause its not a proper COM dll, if you have a closer look, you can see that .net assembly doesnt have any COM specific mechanism to locate the particular DLL (there is no entry in the registry pointing to the location of the dll or does the other application know how to create an instance).
So, to call .net assembly from VB6 you need to do couple of things.
Create public interfaces and implement those interfaces in a class. Only public methods are visible to COM.
Run regasm tools against this assembly to make sure that other COM aware clients know how to create this COMponent and call those methods.
Refer msdn on Regasm and COM Interop.
Hope this helps.
Cheers
Kannan
|
|
|
|
|
i obtain a socket through TcpListener using:
Socket mySocket = myListener.AcceptSocket() ;//myListener is TcpListener
sometimes, i realize that my program will halt at line:
int i = mySocket.Receive(bReceive,bReceive.Length,0) ;
hence, i was thinking to set a receive timeout option, my questions is
(1)is this the correct method
mySocket.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.ReceiveTimeout, 1000)
i put SocketOptionLevel as SocketOptionLevel.Tcp, is it correct?
(2)what will happen when the program come to line
int i = mySocket.Receive(bReceive,bReceive.Length,0) ;
and after 1000 miliseconds and still have not received anything. where will the program execution go?
thank you.
regards
yccheok
|
|
|
|
|
1) I'm using
socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, 60000);
socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 60000);
socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer, 1024);
socket.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.NoDelay, 1);
So I think it should be SocketOptionLevel.Socket. Found it elsewhere on google.
2) Set a breakpoint on that line and trace over it. It will either fire an exception or go to the next line. Don't quite remember. Check the return values for receive as well.
|
|
|
|
|
i try to run an console application through a programmatically created process. i dont want a new console command window to pop up during the process running. hence, i use the following code.
------
System.Diagnostics.ProcessStartInfo pi = new System.Diagnostics.ProcessStartInfo(Application.StartupPath+"\\EncodeFile.exe");
pi.CreateNoWindow = true;
p = new System.Diagnostics.Process();
p.StartInfo = pi;
p.Start();
------
however, the console command window still show up although i oledi set
pi.CreateNoWindow = true;
can anyone tell me the solution?
thank you.
regards
yccheok
|
|
|
|
|
try it with the compiler option /target:winexe
Cheers
Kannan
|
|
|
|
|
You need to set the RedirectStandardInput , RedirectStandardOutput and RedirectStandardError properties of the <EDIT>ProcessStartInfo </EDIT> object to true . If you need to, you can then access the input and output of the console using the StandardInput , StandardOutput and StandardError properties.
E.g.:
ProcessStartInfo psi = new ProcessStartInfo();
psi.RedirectStandardInput = true;
psi.RedirectStandardOutput = true;
psi.RedirectStandardError = true;
psi.FileName = "Path to the exe";
Process p = Process.Start(psi);
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
<br />
((Rectangle)mySquares[i]).X = <br />
((Rectangle)mySquares[i-1]).X;
I have an ArrayList of Rectangles and would like to update the X co-ordinate with the old one but this assignment generates a compiler error "The left-hand side of an assignment must be a variable, property or indexer"
yet the left hand side of this IS a property. Is there a reason for this? do I have to extract/assign the x co-ordinates in a for loop?
|
|
|
|
|
If this is not already in a for loop, then how is the current value of i determined?
in any event, it will fail for i=0 since there is no element whose index = -1.
Perhaps we need a to see just a wee bit more of your code in order to help?;)
|
|
|
|
|
<br />
for (i = mySquares.Count - 1; i > 0; i--)<br />
{<br />
((Rectangle)mySquares[i]).X = <br />
((Rectangle)mySquares[i-1]).X;<br />
((Rectangle)mySquares[i]).Y = <br />
((Rectangle)mySquares[i-1]).Y;<br />
}<br />
I'm trying to update the x,y co-ordinates of the rectangles in the arrary in a Timer.Tic() method.
it tells me that my left operand has to be a property but is Rectangle.X not a property?
|
|
|
|
|
Interesting, try this:
for (int i = mySquares.Count - 1; i > 0; i--) {
Rectangle r1 = (Rectangle)mySquares[i];
Rectangle r2 = (Rectangle)mySquares[i-1];
r1.X = r2.X;
r1.Y = r2.Y;
}
Burt Harris
|
|
|
|
|
Burt Harris (msft) wrote:
Rectangle r1 = (Rectangle)mySquares[i];
Rectangle r2 = (Rectangle)mySquares[i-1];
Unfortunately that won't work either.
The problem is that Rectangle is a value type so the modifications you are doing are being done to the unboxed value which is discarded. Instead, you should create a new Rectangle object and place it back in the collection.
for (int i = mySquares.Count - 1; i > 0; i--)
{
Rectangle r1 = (Rectangle)mySquares[i];
Rectangle r2 = (Rectangle)mySquares[i-1];
mySquares[i] = new Rectangle(r2.X, r2.Y,
r1.Width, r1.Height);
}
[Edit]I should have posted this sooner instead of catching up on CP, Richard beat me to it :P[/Edit]
James
- out of order -
|
|
|
|
|
Rectangle is a struct, so that probably won't work anyway, since you're changing the coordinates of an unboxed copy of your rectangle. Try something like:
for (i = mySquares.Count - 1; i > 0; i--)
{
mySquares[i] = new Rectangle(
((Rectangle)mySquares[i-1]).Location,
((Rectangle)mySquares[i]).Size);
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
Thanks everyone for your replies it is working now (Well at least the assignment problem I had
|
|
|
|
|
Is this the only way to 'fall through' on switch statements?
<br />
int x = 3;<br />
switch(x){<br />
case 0:<br />
goto case 1;<br />
case 1:<br />
goto case 2;<br />
case 2:<br />
goto case 3;<br />
...<br />
}<br />
*->>Always working on my game, teach me
*->>something new.
cout << "dav1d\n";
|
|
|
|
|
|
IMHO something like this would be a cludge that screams poor design.
If you need to use goto to 'fall through' a switch then you need to consider redesigning your application.
<br />
switch(x)<br />
{<br />
case 0:<br />
case 1:<br />
case 2:<br />
DoAction();<br />
break;<br />
.<br />
.<br />
.<br />
}<br />
Probably not what your doing though.
|
|
|
|
|
yeah indeed. perhaps you could consider getting each of your case statements to call functions instead of each other.
not sure what your exact need is, but all i know is from previous experience that fallthrough statements come back to bite you in the butt later when you least expect them.
|
|
|
|
|
No, you can 'fall' through so long as there is no code between the case statements.
And yes, it sucks.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Anyone know how to get system info at runtime. I specifically need to find out what COM ports are installed.
Thanks
-Sam
|
|
|
|
|
Hi Sam,
Take a look at System.Management namespace, its a wrapper for WMI, you might find what you are looking for.
Cheers
Kannan
|
|
|
|
|
Try this out:
private void btnComPorts_Click(object sender, System.EventArgs e)
{
txtOutput.Clear();
string server = @"\\" + txtServer.Text;
ManagementScope ms = new ManagementScope(server + @"\root\cimv2");
ObjectQuery oq = new ObjectQuery("select deviceID from win32_SerialPort");
ManagementObjectSearcher mos = new ManagementObjectSearcher(ms, oq);
ManagementObjectCollection moc = mos.Get();
foreach(ManagementObject mo in moc)
{
txtOutput.AppendText(mo["DeviceID"].ToString());
txtOutput.AppendText("\r\n");
}
}
Matt is a network administrator for an auditing company in the midwest. He is shamelessly looking for Windows programming side work.
|
|
|
|
|
Thanks Matt, worked excellent!
|
|
|
|
|
I've seen many really good examples of how to add scrolling credits to your Visual C++ applications, but I haven't found any yet for a C# Windows application. Are there any out there?
|
|
|
|
|
How can I test for a null string?
if (str == "")
doesn't work if str is a string containing just \0.
|
|
|
|