|
Post in one forum and stick to it.
|
|
|
|
|
I've played with .NET/CLI for a while and have started learning MSIL/CIL.The following code compiles to a .NET executable without warning or error messages. ILASM reports in its output "Assembled global method HelloWorld."
.module HelloWorld.exe
.assembly extern mscorlib {}
.assembly MyAssembly
{
.ver 1: 0: 0: 0
}
.method public hidebysig static void HelloWorldHelper() cil managed
{
ldstr "Hello, World!"
call void [mscorlib]System.Console::WriteLine(class System.String)
ret
}
.class public auto ansi HelloWorld
extends [mscorlib]System.Object
{
.method public hidebysig static void HelloWorld() cil managed
{
.entrypoint
call void HelloWorldHelper()
ret
}
}
My question: how can consuming C# code access the HelloWorldHelper method? For example:
public class Program
{
public static void Main(string[] args)
{
HelloWorldHelper();
}
}
will fail to compile with "csc /r:HelloWorld.exe consumer.cs" with "error CS0103: The name 'HelloWorldHelper' does not exist in the current context."
(In case you wonder why I care about this arcane use, I am writing a compiler that targets the .NET run time.)
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
What would you expect to happen here? Your Main calls HelloWorldHelper which does not exist as a static method in the Program class.
|
|
|
|
|
Don't worry. I just did some more research and found that cross-assembly global references are not supported. I did this through writing MSIL code to consume the global function in another assembly and received a compile error informing me of this issue.
For anyone interested, here's the code and command lines:
.assembly extern mscorlib {}
.assembly helloworld
{
.ver 1: 0: 0: 0
}
.method public static void HelloWorld()
{
ldstr "Hello World!"
call void [mscorlib]System.Console::WriteLine(class System.String)
ret
} Compile with ilasm /DLL helloworld.il
.assembly extern mscorlib {}
.assembly extern helloworld
{
.ver 1: 0: 0: 0
}
.assembly Moo
{
.ver 1: 0: 0: 0
}
.class public auto ansi Program extends [mscorlib]System.Object
{
.method public hidebysig static void Main() cil managed
{
.entrypoint
call void [helloworld]::HelloWorld()
ret
}
} Compile with ilasm printer.il
You will receive something similar to the following error:
Microsoft (R) .NET Framework IL Assembler. Version 2.0.50727.3053
Copyright (c) Microsoft Corporation. All rights reserved.
Assembling 'printer.il' to EXE --> 'printer.exe'
Source file is ANSI
printer.il(17) : error -- Cross-assembly global references are not supported ('HelloWorld')
Assembled method Program::Main
***** FAILURE *****
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
I created a DLL (class library) on C#.NET (2005) and want
to use it as an ActiveX control on a web page (html).
I have checked the box for Make "assembly COM visible" in the
project properties before I build the DLL. Code does do much,
here is my C# code for ctrl
namespace MyActiveXctrlLib
{
public partial class MyUserCtrl : UserControl
{
public string setName
{
set
{
txtName.Text = value;
}
}
public MyUserCtrl()
{
InitializeComponent();
}
}
}
here is my HTML
<title>Untitled Page
<object id="myControl1" name="myControl1" classid="MyActiveXctrlLib.dll#MyActiveXctrlLib.MyUserCtrl" width="288" height="50">
function doScript()
{
myControl1.setName = frm.txt.value;
}
on button click doScript(); is executed .
it sets the setName property of myControl1 i.e. WinForm control.
this code working successfully on IE 7.0 machine having .NET installed on them
but is not working on Machine those dnt have .NET installed on them.
not checked on IE 6.0.
Thanks in advance .
DaTtA
way2datta@gmail.com
|
|
|
|
|
C# cannot target building an actual ActiveX control. You can build a COM-exposed component (like you have already done) that, to IE, LOOKS like an ActiveX control, but, in order for your control to run on the client, the client MUST have the required .NET Framework installed. You cannot get around this requirement.
If you want a control that can be used without the .NET Framework, you'll have to rewrite it in a language that does not require the .NET Framework, like C++.
|
|
|
|
|
|
I think you want the ASP.NET or WPF forums. It doesn't sound like this has anything to do with VB.NET.
I think you mean that when the user presses F1 in their browser (while running your app), you want a help file for your app to come up instead of the help for the browser. AFAIK, you cannot change that behavior.
|
|
|
|
|
I publish my application evry week with latest updated version,
via internet...using CLICK ONCE....
I have take care of autheentication of the publishig person
It publishes fine...
Now Whenever I publish it, after publish,It ask for download latest version or not?
So I cant make the compultion to user to take the latest version...
Is there any option in click once that I can set,
So next time I publish user comapsary has to be get the update version or
It directly loads a new version application without asking user ?
|
|
|
|
|
You can use the ClickOnce API to detect and automatically install the update.
only two letters away from being an asset
|
|
|
|
|
How can I do this ?
Can youi give me steps or msdn link related to that topic ?
|
|
|
|
|
Try here[^]
only two letters away from being an asset
|
|
|
|
|
Hi,
I am working on a WPF application with .Net Framwork 3.5. On my application Window I have a free text box. Is there any class in .Net which helps in determining the datatype of the typed text in the text box?
Eg.
If user types "Vipul1234" OR "Vipul" then the class should determine the data typed in the textbox is of type String
If user types "1234" then the class should determine the data typed in the textbox is of type int
Regards,
Vipul Mehta
|
|
|
|
|
Hi,
what you type in a TextBox is text, hence a string.
it may also represent something else, such as an int, a double, a DateTime, etc.
In order to check, you should call TryParse on each relevant type, and be careful about the order
(so an integer may turn into either an int or a double).
|
|
|
|
|
Hi Luc,
As the value in the textbox would always be text i.e. of string data type.
So how tryparse will determine of its actual type as int or double or some other?
Shilpa
|
|
|
|
|
Well, TryParse, whatever the base class, will try and parse the string; it will fail when the
data does not fit the type you are trying to parse, so a sequence of different TryParse calls
should be sufficient to determine the type. Check the documentation on int32.TryParse, DateTime.TryParse
|
|
|
|
|
Thanks very much... This worked well
Regards,
Vipul Mehta
|
|
|
|
|
Wouldn't it make more sense to use the textbox as it was intended to be used - to capture text - then cast the input to whatever type you need? Even if you're re-using a control for different types, your application should "know" what it's expecting at each point. If that isn't the case, you can try casting the input to various types and catching the exceptions thrown to determine the type. Even so, you're going to get misleading results if, for example, you ask for a password and the user chooses '123456' as a password. Better, I think, to clearly define what you expect at each input opportunity and constrain the input to compatible types.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
Hello,
I have a to create a project wherein I have One Server on which and many clients.
I have to make the functionality that the client will run only if the Server is running.
When the client will start it will send a message to the server and server will respond to that message.
Also i need to maintain a check of number of clients connected to the server.
I have done the Client-Server Connectivity using UDP but i am facing problem in implementing the Check functionality for Client.
Please anyone having some Idea, Thanks in Advance.
|
|
|
|
|
So what's the question?? You haven't asked a question anyone can answer.
|
|
|
|
|
Hello, Sorry.
I want to know how the above mentioned can be done using TCP/IP where i can maintain number of clients connected and when the client gets disconnected so that I can check whether to allow any more clients to connect.
hope You will get the question.
Thanks in Advance.
|
|
|
|
|
All you'd have to do is increment a counter in your server-side client connect code. When a client disconnects from your server, decrement the counter.
If you're using UDP, not TCP, this doesn't mean anything since there are no connections.
|
|
|
|
|
Hello,
Thanks For the reply, but I am not getting how to start.
Please could you give me some code so that i can refer that.
Also i have tried it, but how to check using Tcp_Listener object how many clients are connected.
If I simply increment a counter, Then how will come to know whether the client is still connected to server or it has got disconnected.
I have written some code wherein the client connects to TCP_Listener, but then how could i ensure that the Connected client is still COnnected?
Please Help Me I am getting too much Confused.
Thank you.
|
|
|
|
|
UDP is a connectionless protocol, so the number of connected clients is 0.
Easy
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Actually I wanted to know how this can be done using TCP/IP.
Please if you know then give me some idea or if you have the code please mail me.
Thank you.
|
|
|
|