Click here to Skip to main content
15,897,718 members
Home / Discussions / C#
   

C#

 
GeneralRe: c# change default text at runtime Pin
Andres Manggini28-Apr-03 10:38
Andres Manggini28-Apr-03 10:38 
GeneralRe: c# change default text at runtime Pin
Anonymous29-Apr-03 11:15
Anonymous29-Apr-03 11:15 
GeneralC# (CRL) RichTextBox Control and Fonts Pin
KingTermite27-Apr-03 13:23
KingTermite27-Apr-03 13:23 
GeneralRe: C# (CRL) RichTextBox Control and Fonts Pin
Kannan Kalyanaraman27-Apr-03 19:37
Kannan Kalyanaraman27-Apr-03 19:37 
GeneralASP.NET, C#, XML GHETTO STEEZ Pin
eggie527-Apr-03 12:46
eggie527-Apr-03 12:46 
GeneralRe: ASP.NET, C#, XML GHETTO STEEZ Pin
Chris Austin27-Apr-03 17:14
Chris Austin27-Apr-03 17:14 
GeneralRe: ASP.NET, C#, XML GHETTO STEEZ Pin
eggie528-Apr-03 15:37
eggie528-Apr-03 15:37 
GeneralA complex one..... Pin
Jon Newman27-Apr-03 5:40
Jon Newman27-Apr-03 5:40 
...
Prepare for confusion, but please help.

I have a plugin framework, using reflection.
This works brilliantly and I will release the code eventually. However, one of the plugins is calling an async callback. This throws an invokation exception:

Cannot load type GoogleSearch.GoogleSearchForm, GoogleSearch, Version=1.0.1212.26393, Culture=neutral,<br> PublicKeyToken=null.    at System.Runtime.Remoting.Messaging.MethodCall.ResolveMethod(Boolean bThrowIfNotResolved)
   at System.Runtime.Remoting.Messaging.MethodCall.ResolveMethod()
   at System.Runtime.Remoting.Messaging.MethodCall..ctor(IMessage msg, Boolean needAccessCheck)
   at System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem..ctor(IMethodCallMessage message, AsyncResult ar, Object target)
   at System.Runtime.Remoting.Proxies.RemotingProxy.Invoke(Object NotUsed, MessageData& msgData)
   at GoogleSearch.SearchDelegate.BeginInvoke(String url, String& result, AsyncCallback callback, Object object)
   at GoogleSearch.GoogleSearchForm.search_Click(Object sender, EventArgs e) <br>in c:\documents and settings\administrator.jonny\my documents\visual studio projects\screenmate\googlesearch\google.cs:line 219
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.ComponentManager.System.Windows.Forms.UnsafeNativeMethods<br>+IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.RunDialog(Form form)
   at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
   at System.Windows.Forms.Form.ShowDialog()
   at GoogleSearch.GooglePlugin.LoadGoogleForm()<br> in c:\documents and settings\administrator.jonny\my documents\visual studio projects\screenmate\googlesearch\google.cs:line 36


Now, let me tell you how the app works. The main app gets methods via reflection. And in the end get to this point:
object o = Activator.CreateInstance(t);
// t being the type in question - all correct
MethodInfo mi2 = t.GetMethod("AcceptRect");
Rectangle rect = new Rectangle(this.Location,this.Size);
mi2.Invoke(o,new object[]{rect});


Now that works fine on all plugins, including the troublesome one.
Now in the plugin class, there is a call to another class in the plugin dll. One based on a windows form. The form loads ok.

A button on the form starts an async callback to process some data. NOW THIS DOESN'T WORK.

GoogleSearch.GoogleSearchForm gs = new GoogleSearch.GoogleSearchForm(this.bob);
gs.ShowDialog();

The above opens the form. (This is all within the same dll and namespace)
// the folowing is the call in the buttons click handler

SearchDelegate search = new SearchDelegate(this.Search);
string result;
search.BeginInvoke(url, out result, new AsyncCallback(this.AnnounceSearch),search);


// the following is the delegate decleration
public delegate string SearchDelegate(string url, out string result);



public string Search(string url, out string result)
{
ArrayList ar = new ArrayList();
			
Uri uri = new Uri(url);

WebRequest wr = WebRequest.Create(uri);
WebResponse resp = wr.GetResponse();
Stream s = resp.GetResponseStream();
StreamReader sr = new StreamReader(s);

string t = sr.ReadToEnd();

sr.Close();
return (result = t);
}

public void AnnounceSearch(IAsyncResult iar)
{
SearchDelegate search = (SearchDelegate)iar.AsyncState;
			
string result;
search.EndInvoke(out result, iar);
this.panel1.Controls.Clear();

//this must be invoked because it is adding controls to a form, and needs to be done in the parent thread
MakeControlsDelegate del = new MakeControlsDelegate(MakeControls);
this.Invoke(del,new object[]{result});
}

public delegate void MakeControlsDelegate(string t);

public void MakeControls(string t)
{

ArrayList gr = this.ParseGoogle(t);

foreach(LinkLabel ll in gr)
{
this.panel1.Controls.Add(ll);
}


Ok, I think thats everything now...

Anyway, the above code WORKED PERFECTLY when it was not a plugin and was just a compile time dll.

The only thing i've changed is the fact that the form is being run from a late-binding dll.


"If you just say porn then you get all manner of chaff and low grade stuff."
- Paul Watson, Lounge 25 Mar 03
"If a man is standing in the middle of the forest speaking and there is no woman around to hear him, is he still wrong?"
- Anon



Jonathan 'nonny' Newman
Homepage [www.nonny.com] [^]
GeneralRe: A complex one..... Pin
leppie27-Apr-03 6:20
leppie27-Apr-03 6:20 
GeneralRe: A complex one..... Pin
Jon Newman27-Apr-03 6:31
Jon Newman27-Apr-03 6:31 
GeneralRe: A complex one..... Pin
leppie27-Apr-03 7:19
leppie27-Apr-03 7:19 
GeneralRe: A complex one..... Pin
James T. Johnson27-Apr-03 13:03
James T. Johnson27-Apr-03 13:03 
GeneralRe: A complex one..... Pin
Jon Newman27-Apr-03 13:46
Jon Newman27-Apr-03 13:46 
GeneralRe: A complex one..... Pin
Mark Smithson27-Apr-03 21:43
Mark Smithson27-Apr-03 21:43 
GeneralRe: A complex one..... Pin
Jon Newman28-Apr-03 5:51
Jon Newman28-Apr-03 5:51 
GeneralRe: A complex one..... Pin
Mark Smithson28-Apr-03 8:10
Mark Smithson28-Apr-03 8:10 
GeneralRe: A complex one..... Pin
Jon Newman28-Apr-03 11:53
Jon Newman28-Apr-03 11:53 
GeneralMarshalling char** Pin
leppie27-Apr-03 2:42
leppie27-Apr-03 2:42 
GeneralRe: Marshalling char** Pin
Stephane Rodriguez.27-Apr-03 7:25
Stephane Rodriguez.27-Apr-03 7:25 
GeneralRe: Marshalling char** Pin
leppie27-Apr-03 7:59
leppie27-Apr-03 7:59 
GeneralRe: Marshalling char** Pin
Stephane Rodriguez.27-Apr-03 8:05
Stephane Rodriguez.27-Apr-03 8:05 
GeneralRe: Marshalling char** Pin
leppie27-Apr-03 8:42
leppie27-Apr-03 8:42 
GeneralRe: Marshalling char** Pin
Stephane Rodriguez.27-Apr-03 9:00
Stephane Rodriguez.27-Apr-03 9:00 
GeneralImportRow Question Pin
2sky27-Apr-03 1:50
2sky27-Apr-03 1:50 
GeneralRe: ImportRow Question Pin
Andres Manggini27-Apr-03 17:44
Andres Manggini27-Apr-03 17:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.