|
Wow, that's ballsy for sure. Please do my homework because I waited until the last minute.
|
|
|
|
|
|
|
You don't know anything about C#, but you have to turn in a web site navigation assignment in 4 hours?? Good Luck!
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
You have everything you need in your description above. Break it down into steps. The entire project should take under 1/2 hour even if new to C#
|
|
|
|
|
First step is File -> New -> Project , or Ctrl+Shift+N for you advanced users.
|
|
|
|
|
|
I can call a JScript function from a c# App doing as follows:
SHDocVw.InternetExplorer oIe;
oIe = new SHDocVw.InternetExplorerClass();
Object strUrl = @"C:\blank.htm";
Object o=null;
oIe.Navigate2(ref strUrl ,ref o,ref o,ref o,ref o);
mshtml.HTMLDocument doc = (mshtml.HTMLDocument) oIe.Document;
doc.parentWindow.execScript("alert('Messge from JScript')", "JScript");
MessageBox.Show("Done");
oIe.Quit();
and what happens is that untill the JScrip dialog is closed my app is blocked.
How can i mak the call async? I tryed with BeginInvoke but got errors.
Regards
|
|
|
|
|
sterenzi wrote: but got errors.
What errors? We can't see them from here.
led mike
|
|
|
|
|
I get what follows:
An unhandled exception of type 'System.InvalidCastException' occurred in mscorlib.dll
You can't get with the code i provided, I'll put the sample code for errors in a few mins.
|
|
|
|
|
OK, if you try the following code you can get the error,notice that I'm not sure this is the best way to follow...
delegate Object execAsyncJScriptDelegate(string param, string lang);
private void button2_Click(object sender, System.EventArgs e)
{
SHDocVw.InternetExplorer oIe;
oIe = new SHDocVw.InternetExplorerClass();
Object strUrl = @"C:\blank.htm";
Object o=null;
oIe.Navigate2(ref strUrl ,ref o,ref o,ref o,ref o);
mshtml.HTMLDocument doc = (mshtml.HTMLDocument) oIe.Document;
try
{
execAsyncJScriptDelegate jFunc = new execAsyncJScriptDelegate(doc.parentWindow.execScript);
IAsyncResult ar = jFunc.BeginInvoke("alert('Message from JScript')", "JScript", null, null);
MessageBox.Show("Done");
oIe.Quit();
while (!ar.IsCompleted)
{
Application.DoEvents();
}
jFunc.EndInvoke(ar);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
|
|
|
|
|
Well in .NET 2.0 I emulated your attempt using WebBrowser.Document.InvokeScript(). It did not throw an exception but the script did not execute and the IAsyncResult is completed upon return. So it appears that async invocation of scripts might not be supported.
led mike
|
|
|
|
|
I have a windows application from which I "call" a method from a web service. The method returns an array of some objects (objects are from a class I created and they are located on the service side.)Objects have their public methods.
Now, on the client side (the win application), I accept that array, but I can't access the methods of the object... Why?
The code is something like this (the client side):
Service srvce = new Service();
Service.MyClass[] arrayObjects = new Service.MyClass[1000];
arrayObjects = srvce.GetArrayOfObjects(); //this returns the array I was talking about
//since that class has a public GetMyProperty() method, I should call that method from tha client side, right?
int myProperty = arrayObjects[0].GetMyProperty();
//but that doesn't work, I can't call any of the methods... IntelliSense gives me nothing after arrayObjects[0]
//it doesn't work when I do the conversion
int property = (arrayObjects[0] as Service.MyClass).GetProperty();
So, I can't call the methods, it's like they are private - and they're not, they're public, I just can't see them from client, and why is that?
I'm stuck... Help!
|
|
|
|
|
Are the objects in the array marked as [Serializable]? When you debug, can you see the objects in the array?
|
|
|
|
|
Well, actually, they're not marked as [Serializable]. During debugging, I can see there are 5 array members, and the debugger returns the correct type (MyWebService.MyClass, for example), but that's it, I can't access them, I can't do anything with them. Now, that's probably because that array of objects are created on the service side, and they sre returned to the client. Maybe it would help if I instantiated the array on the client, and send that array to the service to be "filled"? But the problem is the size of the array - I can't predict that, and it would be silly to set it to 100 and it's count is only 3.... Maybe I can use ArrayList instead? The problem is that I'm new to web services (although not to win forms programming), so I don't know much about serialization... So any tips will be appreciated...
|
|
|
|
|
I want to create one bluetooth application which can send commands to a robot which is having a bluetooth receiver.I am clear till the application that sends the bt signals to robot but from receiver side what should I do?Can Any one tel me.How can I do programming there in C#.
nishu
|
|
|
|
|
Hi guys,
I have a class that extends an IMenuProvider interface and belongs to a plug-in project. In the UI project(other project) I've developed a menuService class that finds plug-ins that implement a IMenuProvider interface and execute the constructor method by using the invoke method. Here's the code.
<code>...
Type[] types = assembly.GetTypes();
foreach (Type type in types)
{
if (type.GetInterface("IMenuProvider") != null)
{
if (!ht.ContainsKey(type.FullName))
{
ConstructorInfo cinfo = type.GetConstructor(System.Type.EmptyTypes);
IMenuProvider imp = (IMenuProvider)cinfo.Invoke(null); **
ht.Add(type.FullName, imp);
RegisterProvider(imp);
}
}
}
...
</code>
So what happens is the line marked with ** returns an error saying "Unable to cast object of type 'TestPlugin.PluginMenuProvider' to type 'Enki.UI.ComponentModel.IMenuProvider'."
I know that I’m attempting to invoke the constructor method of the subclass PluginMenuProvider through the extension IMenuProvider but i don’t want to have to specify every subclass that extends the IMenuProvider interface.
Now, my question is how can i invoke the constructor without having to declare and than cast each class type that extends the interface IMenuProvider like the line marked with ** does?
Best regards.
Pedro M.
|
|
|
|
|
Jost Pedro wrote: execute the constructor method by using the invoke method
Invoking constructors might have a place but I would avoid it. From a design perspective I would use a Creational Design Pattern.
led mike
|
|
|
|
|
|
How about simply using Activator.CreateInstace[^] instead, especially considering that the constructor doesn't take any parameters? That's the typical way in which objects are created using reflection.
Type[] types = assembly.GetTypes(); foreach<span> (Type type </span>in<span> types) </span> { if<span> (type.GetInterface(</span>"IMenuProvider"<span>) != </span>null<span>) </span> { if<span> (!ht.ContainsKey(type.FullName)) </span> { IMenuProvider imp = (IMenuProvider)Activator.CreateInstance(type);
...
|
|
|
|
|
Hi
how to programmatically get the name of the user who is currently logged-in to the windows.
regards
sAqIb
"Our scientific power has outrun our spiritual power. We have guided missiles and misguided men."
Dr. Martin Luther King Jr.
|
|
|
|
|
System.Environment.UserName
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
Hey all,
I have an abstract class which defines some functions, WITHOUT declaring them virtual .
When I derive from that class, I simply use the override keyword and declare the same signature for the function.
It works perfect AFAICT...
Is there any place we are forced to use the virtual keyword?
Is it wrong not to use it?
Does it break the polymorphism rules?
Thanks in advance,
Shy.
|
|
|
|
|
That's weird. In order to be able to mark a method with override the base class method must be either itself override , abstract or virtual .
... or on my compiler it does anyway.
Regards,
Rob Philpott.
|
|
|
|
|
I do declare the functions as abstract ...
Just not virtual .
|
|
|
|