|
Thanks mate. I will try to do something about it.
It's not very important. It can wait. It is, if I use gradient color.
-- modified at 11:33 Monday 20th February, 2006
|
|
|
|
|
Hi everybody.
Currently I'm developing a mechanism to load other C# dlls so that they can act as plugins for my application. This is what I have so far, the code is inside a DLL which is loaded by a different C# app again:
Assembly dll = Assembly.FromFile(filename);
Type entry = dll.GetType("PluginTest.Entry");
Entry start = (Entry)Activator.CreateInstance(entry);
start.Go();
This loads the dll filename , loads the Entry class from namespace PluginTest and executes the method Go() .
This works fine in my test-solution where all files reside in the same folder.
Now comes the awkward part: If I move my DLLs (the reflection loader and the plugin dll) to a different folder, then suddenly the dll.GetType() part fails with an ArgumentException .
Can someone tell my what's wrong with my code here when everything works fine in my testing "sandbox"? It's not the LoadFile part which is failing from outside this scenario, as I think
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Did you try Assembly.Load() instead? It works for me when the plugin is not in the same folder.
I assume you have interface setup for the class, right?
-- modified at 20:57 Saturday 18th February, 2006
[edit] Sorry, I was looking at wrong part of the code, Assembly.Load() was used to check whether the plugin can be loaded. this is where the assembly is really loaded on my app:
Type ObjType=null;
Assembly assembly = null;
assembly = Assembly.LoadFrom(path); <---- full path
if(assembly != null)
{
ObjType = assembly.GetType("you.class.here");
}
if(ObjType != null)
{
object[] args = new object[2];
args[0] = cm;
args[1] = catalog;
this.database = (IDatabaseInterface)Activator.CreateInstance(ObjType, args);
}
-- modified at 21:02 Saturday 18th February, 2006
[edit again]
Some other stuff that I found after 2 painful days of trial and error
1. Have an interface for the class
2. You must put the interface class in a seperate assembly. Putting it in your main assembly won't work.
3. You have to keep the assemblyversion (main, interface, the plugins) a constant and may need to sign the assembly too.
|
|
|
|
|
DarkElv wrote: Some other stuff that I found after 2 painful days of trial and error
1. Have an interface for the class
2. You must put the interface class in a seperate assembly. Putting it in your main assembly won't work.
3. You have to keep the assemblyversion (main, interface, the plugins) a constant and may need to sign the assembly too.
thanks so far for the detailed description! This looks like a rather painful procedure just for some reflection code. Isn't there something simple like GetProcAddress() for .NET?
1) Entry is actually an interface
2) it's defined in the same assembly where the reflection code is
3) what's the deal with the assembly version and signature?
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
You can't create an instance of an interface.
---
b { font-weight: normal; }
|
|
|
|
|
Yeah, I used the an article here describing how to make a plugin, and then I encountered the same problem that you have when I move the dll to some other folder. So ended up I search various news groups and finally make it worked.
Along the way I read something about the assembly version, and if the interface is included in the main assembly, and you creates another dll that includes the interface in that dll, they will be considered 2 different interface, as everytime you compile them, a new version and new guid will be generated. I didn't bother to see if not making the version and signature the same still work as it is working now
So for (2), make a standalone dll for the interface and reference it in both your main and your plugin.
|
|
|
|
|
DarkElv wrote: So for (2), make a standalone dll for the interface and reference it in both your main and your plugin.
Just did that. My testing "sandbox" still works like a charm, but outside now I get a FileNotFoundException which says File or assembly EntryInterface could not be found... .
These files are all in the same directory:
- Entry.exe (loading the reflection dll)
- EntryLoader.dll (doing the reflection stuff)
- EntryInterface.dll (defining the interface class)
- SomePluginDLL.dll
SomePluginDLL and EntryLoader.dll both have a reference to EntryInterface.dll, but this way I get a FileNotFoundException outside of my testing scenario.
Thanks for your effords so far
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I can send you a sample solution if you like.
|
|
|
|
|
Yeah, that would be great
my mail is: gregismurf@gmx.de
Thanks!
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Greeeg wrote: Type entry = dll.GetType("PluginTest.Entry");
You need to specify the fully qualified assembly name AFAIK. ie
"PluginTest.Entry, Plugin"
|
|
|
|
|
I have been through various books to learn C#. The books have simple examples and unrelated examples from chapter-to-chapter. I am now trying to think of a C# Windows Application that I can create to help cement C# into my brain.
I have thought about doing a project that will implement the game hangman. I want to somehow make the project database-driven too (with sql).
But was wondering if anyone might have some other ideas, or thoughts about the hangman idea? Maybe some of you have taken an official class where you had to do a major class project utilizing C#?
|
|
|
|
|
Database is always a good choice - get some values, set some values, display the values on some controls. If your conception of hangman involves graphics (drawing on the windows form), that would not be particularly typical of what a person would do to get a "hang" of C#. But there is no right, no wrong. It is upto you. Drawing on the screen is real fun - but my personal view is most of the time in the professional world, you would not need that unless you are working for may be an ad company. Best of luck!
Koushik Biswas
|
|
|
|
|
In addition to the post by Koushik Biswas I'd say that Hangman is quite a good starting point. You can use the database to store a dictionary of words and phrases. Database interaction is probably the most common activity in the business world (certainly, I spend most of my time writing code that interacts with the database).
To get an understanding of more complex logic code, you might try a strategy game. If you are feeling advernturous you could then refactor it so that the computer acts as one of the players. That will get you learning about design patterns as well - this is an excellent transferrable skill that will go beyond C# into many other languages (very important in the modern world where the language of choice changes every few years)
LuluSailor wrote: Maybe some of you have taken an official class where you had to do a major class project utilizing C#?
When I was in high school (16 years ago now) the project was to create a game like noughts-and-crosses or nim.
When I did C++ classes at university (13 years ago) the project set was to create a simple vector drawing package. You could place various shapes (the model in the View-Controller-Model pattern) onto a drawing surface (the view - you could create a custom control for that). Each shape could be selected and moved or resized. Think of is as a very simplistic powerpoint type of application, but with only one slide. The picture could be saved and loaded from disk (so this gets you some practice with File IO, or XML Serialization) and it gives you practice designing a file format.
I hope this helps. I've sprinkled a few good keywords through that you might like to search on. It's all good practice.
ColinMackay.net
Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?
|
|
|
|
|
Hi friends
I need some help on generating left and right mouse clicks anywhere on the desktop or any window opened in it as a matter of fact, in c#. Elaborating further, i want to develop an application in c#, which when run wud click(left or right click) at any specified position on the desktop screen as if i were clicking on that specified position(say "My Computer" icon) uing my mouse.
can someone pls guide me into creating it, i ll be grateful
thanks.Regards.
SB
-- modified at 17:31 Saturday 18th February, 2006
|
|
|
|
|
http://www.developerfusion.co.uk/show/276/
|
|
|
|
|
How can show a contect menu by left (not right of default) click a button?
|
|
|
|
|
Handle the MouseButtonDown (or whatever the name is) event, which gives you which mouse button is pressed and the point where it was pressed. Display the menu there yourself in your MouseButtonDown handler.
|
|
|
|
|
if i give that coordinates i get the context menu in 0,0 screen coordinate not at the button relative
|
|
|
|
|
This works for me, displaying the context menu at the correct position. Note I'm using the right mouse button, but that shouldn't make any difference. I'm handling the MouseDown event of a control on the form, though.
<br />
private void datagridview_MouseDown(object sender, MouseEventArgs e)<br />
{<br />
if (e.Button == MouseButtons.Right)<br />
{<br />
.......<br />
headerContextMenuStrip.Show(dataGridView, e.X, e.Y);<br />
}<br />
}<br />
|
|
|
|
|
|
I have a program that displays data in a DataGridView in C# (but if you are only familiar with the DataGrid, please read on because any advice you have will still be applicable). The DataGridView is bound to a SQL Server table with a typed DataSet. I need to do a few things that I'm having difficulty with, and I'm hoping someone can point me in the right direction.
1) Some columns of the database table contain numbers, like 0, 1, 2, that represent things. For example, in one column, 0 and 1 in the database table should be shown as false and true in the DataGridView. In another case, a small range of numbers in the database table should be represented as a corresponding value from a list of strings. In the DataGridView, these columns are combo box columns that are NOT bound to any data source (I enumerate the possible combo box values when I create the DataGridView). Currently they contain the numbers from the database. How can I get them to contain the corresponding strings? I tried using the CellFormatting and CellParsing events, but they don't work properly due to the many DataError events caused by changing the cell values from short or int (as in the database table column) to string (as in FALSE/TRUE). Are the ValueMember and DisplayMember attributes of the column of any value to me? Do I have to create an unbound column? If so, how do I keep that column sorted as the user sorts the bound columns in the DataGridView?
2) One combo box column of the table gets its combo values loaded from the keys of another table (not bound to it, but I do it manually). But if my table has "foobar" in a column and the keys from the other table that get loaded into the combo box include "FOOBAR" (upper case), I get a data error event. Is there some way to make it case insensitive?
Thanks for any help.
-- modified at 17:24 Saturday 18th February, 2006
|
|
|
|
|
plz i want a code to make a face detection
i will be grateful if this code be in c# or matlab
and any one have this code send me it in hythem18@hotmail.com
thanks in advance
haitham
|
|
|
|
|
This is cutting edge technology. There are two choices:
1. Read the research papers and figure out how to implement the algorithms presented in a useable form.
2. Buy an off-the-shelf module that you can plug into your application.
Both options are expensive. The first is expensive in time, the second is expensive in cost.
ColinMackay.net
Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?
|
|
|
|
|
the site is under construction so both options are failed
any one else can help?
haitham
|
|
|
|
|
eng:haitham wrote: the site is under construction so both options are failed
The context has been lost from that statement. What site are you talking about?
eng:haitham wrote: any one else can help?
I'd be very surprised if anyone here is expert enough to give you face recognition code in C#. As I said the technology is very new. Most of what is availalble will still be in research labs.
ColinMackay.net
Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?
|
|
|
|