|
Hi All
I have created a new c# dll and want to use that in VB6. When I add a reference to the dll in vb, it throws an error "Cant add reference to dll".
Any help
$iva
|
|
|
|
|
Take a look at the help topics under "Exposing .NET Framework Components to COM". I think that will cover what you need.
Burt Harris
|
|
|
|
|
Burt Harris (msft) wrote:
Take a look at the help topics under "Exposing .NET Framework Components to COM".
MSDN Article link[^]
Nick Parker
Not everything that can be counted counts, and not everything that counts can be counted. - Albert Einstein
|
|
|
|
|
You didn't create a DLL, you created an assembly. You cvan't use asseblies in VB6.
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Hi,
It is possible to use .net assemblies in VB6 using Interop.
You need to run regasm tool with /tlb or /codebase option, so that it creates a wrapper for the .net assemblies to be called from COM.
Alternately you can directly reference MSCorLib / MSCorRe from VB6 and create instances of framework components(like HashTable or any other class). I dont have the sample with me right now, but DonBox demonstrated this sometime back in TechEd.
regards
Kannan
|
|
|
|
|
Ooh!
Cool!
But does the .NET redistributable have to be installed on my customers computer??
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Rickard Andersson wrote:
But does the .NET redistributable have to be installed on my customers computer??
Absolutely, its just a wrapper that is generated by the regasm dll, something like a proxy. The runtime kicks in once you start calling managed methods.
Cheers
Kannan
|
|
|
|
|
Kannan Kalyanaraman wrote:
something like a proxy
<changed_subject>
Could you tell me where I could learn more about what a proxy is and how it works etc.?
I want to learn...
</changed_subject>
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
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.
|
|
|
|