|
You are likely having a threading issue. Try as the AsyncCallback is invoked from another thread. Do the following:
from your control:
Invoke(mi.Invoke, new object[]{o, new object[]{rect}});
Eek. Dunno if that will work, but give it a try
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
I'm not sure I understand where i'm to place that.
The plugin is activated and invoked from a form in the main app and main thread.
From the new instance of the plugin, the plugin class loads the plugin form.
object o = Activator.CreateInstance(t);
MethodInfo mi = t.GetMethod("SomeMethod");
mi.Invoke(o,null);
does the above code create the instance of the object in a new thread, or the same thread as the method that runs it?
"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] [^]
|
|
|
|
|
Jonny Newman wrote:
does the above code create the instance of the object in a new thread, or the same thread as the method that runs it?
That will create the object in the calling thread.
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
Jonny Newman wrote:
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.
Just judging from that I would say there is a problem with the application resolving assemblies.
In the FrameworkSDK\bin directory (located within VS.NET's install folder) you'll find FUSLOGVW.exe which will let you see what the runtime is trying to do to find the assemblies it needs to load.
Run that, make sure you check the "Log Failures" checkbox, then run your application. You should see where it is expecting to find the assemblies it is loading, and if it fails to load an assembly the plugin depends on.
HTH,
James
"It is self repeating, of unknown pattern"
Data - Star Trek: The Next Generation
|
|
|
|
|

The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:\WINNT\Microsoft.NET\Framework\v1.0.3705\fusion.dll
Running under executable C:\Documents and Settings\Administrator.JONNY\My Documents\Visual Studio Projects\ScreenMate\ScreenMate\bin\Debug\ScreenMate.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = GoogleSearch, Version=1.0.1212.29205, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = C:\Documents and Settings\Administrator.JONNY\My Documents\Visual Studio Projects\ScreenMate\ScreenMate\bin\Debug\
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = NULL
Calling assembly : (Unknown).
===
LOG: Processing DEVPATH.
LOG: DEVPATH is not set. Falling through to regular bind.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Post-policy reference: GoogleSearch, Version=1.0.1212.29205, Culture=neutral, PublicKeyToken=null
LOG: Attempting download of new URL file:LOG: Attempting download of new URL file:LOG: Attempting download of new URL file:LOG: Attempting download of new URL file:LOG: All probing URLs attempted and failed.
Well, it seems to state that the dll was never loaded.
However, the dll must have been loaded because the form the button is on is in that dll, code is actually being run from it. It is definately something to do with the async callback.
Should I try starting the Activator.CreateInstance() in another thread?
Threading isn't my strong point.
"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] [^]
|
|
|
|
|
I don't think your problem has to do with threading. It doesn't matter on which thread you are trying to create the object, the CLR cannot find the assembly file that the object is defined in.
Which files do you have as part of your application? Presumably you have an application exe and the GoogleSearch.dll is the plugin.
Is the GoogleSearch dll located at any of the locations in the output above? If so is the dll of the same version listed above (i.e. 1.0.1212.29205)?
Regards
Mark Smithson
|
|
|
|
|
googlesearch.dll is located in the /plugin directory. But I don't see how this causes a problem since the plugin is already loaded and working, so the file location shouldn't matter, but obviously if its looking in the wrong place for it then there must be a problem.
On the point of asyncs. Would it help if I made the async methods static, might this help resolve stuff?
"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] [^]
|
|
|
|
|
I'm not really sure what you mean by 'loaded and working'. You code and the errors imply that the CLR cannot load a type.
This is because your plugin directory is not in the probing path for the application. Your will either need to change your applications config file to include this directory, or manually load the assemblies.
Try adding the following to your app.config file
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="plugins"/>
</assemblyBinding>
</runtime>
</configuration>
Also have a look at the following MSDN link for further information on the how the CLR locates assemblies
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconhowruntimelocatesassemblies.asp
Regards
Mark Smithson
|
|
|
|
|
Cheers that seems to have done the trick! I knew it would be simple
"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] [^]
|
|
|
|
|
Hi all (and S.Rod. as you are most likely to answer this )
Say I have a C function:
char** Foo(int* size);
Now in MC++ its pie and I can just go:
int size = 0;
char** buffer = Foo(&size);
String* results __gc[] = new String*[size];
for (int i = 0; i < size; i++)
{
results[i] = new String(buffer[i]);
free(buffer[i]);
}
free(buffer);
But how do I approach this from a Marshalling POV in C# given I have Foo as a DllImport defined as IntPtr Foo(out int size) ? How do I access the individual char* and the finally free the returned IntPtr? My attempts has failed miserably
Thanks
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
Here is how I got it to work,
C implementation :
extern "C" __declspec(dllexport) char** foo(int *nSize);
__declspec(dllexport) char** foo(int *nSize)
{
*nSize = 2;
::MessageBox(NULL,"unmanaged foo call","message",MB_OK);
char **lpstr = (char**) CoTaskMemAlloc( 2*sizeof(LPSTR) );
lpstr[0] = (char*) CoTaskMemAlloc( 100 ) ;
strcpy(lpstr[0], "string1");
lpstr[1] = (char*) CoTaskMemAlloc( 100 ) ;
strcpy(lpstr[1], "string2");
return lpstr;
}
Now for the managed part,
[DllImport(@"..\bin\foo.dll", CharSet=CharSet.Auto)]
static public extern IntPtr foo(ref int nSize);
int nSize = 0;
IntPtr pData = foo(ref nSize);
for (int i=0; i<nSize; i++)
{
IntPtr pString = Marshal.ReadIntPtr(pData, 4*i);
MessageBox.Show( Marshal.PtrToStringAnsi(pString) );
}
|
|
|
|
|
.S.Rod. wrote:
Marshal.ReadIntPtr
Dope, how did I miss that one again (some bells ring)? PtrToStringAnsi frees the string, would FreeHGlobal(pData) at the end be right then?
Thanks for the reply
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
|
Hmm, I allocated the unmanaged memory with calloc, is FreeHGlobal an alias for that or do i need to dllimport that?
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
calloc , malloc or even new are not good when you are crossing the managed boundaries. Indeed, the only way to make sure the allocated memory is NOT freed or moved when it's being marshaled is to allocate the memory block in a shared space, hence CoTaskMemAlloc (for allocations), and FreeCoTaskMem (for deallocations).
|
|
|
|
|
I have this program where I'm supposed to copy a datarow into another databale. Herefore I use the ImportRow method. The problem is that this method does not return the newly created datarow. Can anyone tell me how to get the new datarow that is created after calling ImportRow? Or is there a better way to copy a datarow between tables?
Thanks in advance
|
|
|
|
|
Hi,
DataTable.LoadDataRow might work better for you.
Hope this helps.
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
Woops, overlooked that one
Thanks Andres !!! 
|
|
|
|
|
can anyone tell me when the treenodes are drawn,when the background is redraw and when the treeview is scrolled what event is raised?
|
|
|
|
|
Use Spy++ to inspect fired events
Regards
|
|
|
|
|
Hello,
In an application I am running I would like to be able to shutdown IIS's FTP
service if a given condition is met. Is there a way to access the FTP to be
able to shut it down without having to shutdown all of IIS (I have a couple
of websites I would like to keep running). I am using C#.
Thank you,
Paul
|
|
|
|
|
You should be able to just access the FTP service on the box by using the Service Control Manager APIs.
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
Jörgen Sigvardsson wrote:
If the physicists find a universal theory describing the laws of universe, I'm sure the a**hole constant will be an integral part of that theory.
|
|
|
|
|
I'll be darned if I can find a simple code on the entire internet to implement a ProgressBar for a common File.Copy procedure. One that actually show real-time progress and not just a timer or
min-max settings. Help
File.Copy(txtAudioSourceDir.Text + txtAudioSourceFile.Text);
|
|
|
|
|
I don't think there is a framework way for you to track the progress of the copy. The only way I see you doing it is to read the bytes into abuffer and then write them again. From that you can get your progress values on the number of bytes read/written.
"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] [^]
|
|
|
|
|