Good! I hope I didn't offend you talking about polymorphism. I just usually make assumptions if nothing is indicated in a post to avoid constant reposting to provide more information. If nothing else, someone googling for answers may find our little thread useful (which is why I dislike forum members taking questions directly to me via email - it doesn't benefit the community).
for a testproject I have to load an assembly from a path different to the execution path of my application. the assembly I want to load references other assemblies, which are not system assemblies or assemblies referenced by my application.
the way I load this assembly is easy and works: Assembly MyAssembly=System.Reflection.Assembly.Load(AssemblyPathandName);
when I enumerate the members of a class of this assembly and the member (for example a method) has a returntype which is declared in a referenced (but not yet loaded) assembly, my application crashs.
now my question:
how can I load the referenced assemblies or how can I change the searchpath of my application, so that the referenced assemblies can be found and loaded automatic??????
There are a few ways that assemblies are found. First, the CLR will read from <runtime> section of the .config file and see if you've configured any paths for bound assemblies. The application will then use assemblies in the Global Assembly Cache (GAC), starting with native (pre-JIT'd) assemblies first, then the other assemblies (those not pre-JIT'd). Assemblies are then used out of the application directory (the directory where you .exe executable is located), followed by any additional subdirectories configured in the <probing> section of you .config file.
You can also handle the AppDomain.AssemblyResolve event and specify from where the assembly should be loaded (for example, from a different path, across the Internet/an intranet, or even from some Stream), but it's typically better and easier to maintain to work with the CLR and and let Fusion (the assembly binder) do its job.
We have an assembly that is in the GAC, but it’s a .NET component that is used inside visual studio itself. Ie it’s a .NET assembly control you drag onto a windows form application. I am trying to install the assembly on a remote machine (installshield devstuio 9) and get it to show up as a reference automatically in vstudio2003. How can I automatically add a reference to Visual studio in an installer / registry hack / command line that links to an assembly in the GAC? Without having to browse for it from the GAC.
For some weird reason, VS.NET doesn't see assemblies in the GAC. You have to add a registry key under HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\AssemblyFolders (see the existing ones for examples). Add the path to the assemblies outside the GAC, though it would be good to add the assemblies to the GAC, too, since it bolsters versioning and - if you ngen then (pre-JIT / generate native code for the target machine) - they'll be much faster to load.
So, the project that references those DLLs will link against the assemblies outside the GAC (the ones in the path that you added to the registry key above) but when you run the application, they'll use the assemblies out of the GAC.
First of all, Heath, I'd like to thank you so much for contributing so much to this community. Man, I've opened the C# page, and all the threads I saw were answered by you! Now I'm saying this regardless of whether you answer my question or not. Although I might become nasty if you don't!!! Just kidding
Say I have a number of InternetExplorer objects (say 3). Say I have all of them attached to one DownloadComplete event, which does the following:
// First, save the document's source to a string for processing.<br />// Second, actually process this string, and update a database.<br />
1- When I do InternetExplorer.Navigate2(...) any page, this does not stop the code execution, correct? In other words it sort of starts in a different thread?
2- Should I be taking any measures to prevent the DownloadComplete from being accessed while it's already executing? In other words: what happens if one InternetExplorer object finished downloading the document, started executing the code attached in the event handler, and while it's executing it, another InternetExplorer finishes and tries to execute it?
My God, I really sound dumb to myself, I'm sure some people look at this and sigh! Again, thank you for answering.
"A good friend, is like a good book: the inside is better than the cover..."
I think it is safer to start a new thread in that event and do lock and unluck for that string that you process it,cause even each handler run on seprate thread if you have some public variable that changed there it will cause problem or uncorrect data. I hope I was clear.
uhmm,let me explain . Imagine you have a public variable named a. You have two thread than wants to change this value, then what will happend? I'm not sure in the situation that you register one method as an event handler for two control this will happend too.It is called Thread Synchronization . You can see this article to understand more and search CP for other information about threading for more info and samples:
You have to lock against the same object (for example, the Type of the current object will always be the same) otherwise the lock doesn't make a difference. Take a look at the System.Threading namespace, specifically the Monitor class (which the lock keyword compiles down to like the following):
If the object called syncRoot is different for every call, the monitor will lock against different objects and will not block pending requests to enter the synchronized section.
There are two things you should take into consideration when choosing an object to lock. If you want a method (especially a static method) to be synchronized, lock against a static object (such as the Type, which is recommended, but you can use a static object reference as well). If you want methods to be synchronized only for a given instance, lock against an object member of the instance of your class.
This might take a few words to explain, so please bear with me if you will:
I'm chopping the data of a .WAV file into segments each of length 256 samples. After this segmentation is done, let's say I have N segments. My N by M multidimensional array is called WaveSegments[N,M].
Now, I want to display each of these segments in a UserControl I've made, and want to cycle through the segments by means of an up/down control.
So, for example, clicking once on the up control would change the number from 1 to 2, and the display would change from the samples of WaveSegment to WaveSegment.
It seems that using collections would ease coding tremendously, but I seem to be running into any number of syntactical problems.
Could somebody please demonstrate to me how I could do this?
Actually, using any kind of IEnumerable or IListSource would be great. You can data-bind the collection to the up/down control and use the CurrencyManager.Position property to adjust the position. For more information about data-binding properties and data sources, see Control.BindingContext and CurrencyManager. This would save you from the mess of handling all this yourself. When used correctly, other controls bound to the data source are updated when the position of the current element in the data source is changed.
At any rate, what are the "syntactical" problems? For ease, extend CollectionBase and override the methods (or implement new methods with strongly-typed params that call the CollectionBase's methods) and most of the rest of the work is already done (which uses an ArrayList to back the elements).
No need - see the documentation for the CollectionBase class in the .NET Framework SDK (just type "CollectionBase" (without quotes) in the Index) and you'll see an example. Be sure to read the documentation - if not skim it over to see what's available in the base class library - especially when starting out.
For the simple drag-n-drop method which generates the RCWs (COM interop assemblies) is to custom your toolbox. Open your toolbox (contains the design objects like a Label or a Button), right-click and select "Customize Toolbox" or "Add/Remove Items" (depending on version of VS.NET). Find the "Adobe Acrobat Control for ActiveX" and "Microsoft Office Spreadsheet Version", where Version is 9.0 or higher (introduces the Office Web Components, or OWC).
If you want to host an actual Excel Spreadsheet like Excel does, you'll either have to dig deep in Active Document Containers and implement several redefined COM interfaces in a class to contain the Active Document (which describes Word docs, Excel sheets, and many other formats), or wait for .NET 2.0 which introduces the ActiveDocumentContainer which already does this, but you'll still have to worry about hosting the toolbar (at least for now in the alpha stages). This can be difficult as well. The OWC edition of Excel already has the toolbar built-in and contains custom design commands.
For the Acrobat control, you can specify a src for the PDF document, either at design-time or at runtime.
You can further hide the application window by setting psi.WindowStyle = ProcessWindowStyle.Hidden.
You can also reference the Microsoft.Office.Excel primary interop assembly (you can generate them yourself, but it's better to use the official ones from http://msdn.microsoft.com/library/en-us/dnoxpta/html/odc_oxppias.asp[^]) and print the spreadsheet. This uses an out-of-process automation server (Excel.Application) to load and print the document: