|
Unfortunately that won't work, if you follow the code posted closely. "Plugins\" is given to the path, and "*.dll" the mask of the file. using your method, and without trying it, I'd guess it'd look for Plugins\Plugins\*.dll and crap out because the path doesn't exist. Also, you forgot a "\", should be "Plugins\\*.dll" or @"Plugins\*.dll", but that's just me being a perfectionist.
I figured out what the problem was, anyway, to a point. I forgot to inherit MarshalByRefObject, but adding that has caused other problems. Namely when code returns to the Manager from the Finder, I get a file not found exception when copying the Finder's array to the array in the Manager. Note the Bold line:
AppDomain domain = AppDomain.CreateDomain("PluginLoadingDomain", null, setup);
Type finderType = typeof(PluginFinder);
PluginFinder finder = (PluginFinder)domain.CreateInstanceFromAndUnwrap(
finderType.Assembly.Location, finderType.FullName);
FoundPlugins = finder.Search(pluginPath);
AppDomain.Unload(domain);
It seems that my main appdomain wants to load the files, based off the fusion binding logs (Mentions that cant load file under \Debug\, instead of \Debug\Plugins\), so any help there would be appreciated.
|
|
|
|
|
Out of my league, obviously
(path + "\\Plugins\\", "*.dll")
iAmEntity wrote: @"Plugins\*.dll", but that's just me being a perfectionist
The compiler interprets them very differently, so it's not an insignificant detail. I got them mixed up regularly, until I changed the syntax-coloring of the C#-verbatim string. In my defense, CP doesn't have syntax highlighting (yet)
I are troll
|
|
|
|
|
Eddy Vluggen wrote: Out of my league, obviously Sniff
Really, it's out of my league too, but jumping into the deep end is how I learn
Eddy Vluggen wrote: it's not an insignificant detail
In this context, i think it is, due to the highlighting we have while coding. Like you mentioned, we don't have that here, so its negligible. As to the code you just posted, still wouldn't work . In this case, the variable path IS "Plugins\". The problem is not in the search method, but in the second method, TryLoadingPlugin. Basically, it was an OOP fart on my behalf in regards to the MarshalByRefObject thing.
|
|
|
|
|
hello friends,
i have a doubt how to write coding for login page in ASP dot net with c# coding????
plz send your answers to me
as quick as possible
|
|
|
|
|
karthimca143 wrote: as quick as possible
Well Google[^] returned over 6.5 million results in 0.19 seconds - is that quick enough for you?
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
I'm writing a program which runs on a specific directory with images, reads them to a Bitmap file and then resize them, and add the resized image to a Bitmap hashmap. The naive code to do this is like this:
Bitmap bmp = new Bitmap(flFileArray[i].FullName);
Bitmap bmp2 = new Bitmap(bmp, (int)(nudWidth.Value / nudNumOfPics.Value),
(int)(nudHight.Value / nudNumOfPics.Value));
m_hshBitmapArray.Add(bmp2, GetAvgPixelVal(bmp2));
It's quite simple, but i'm wondering if there is a faster way to do this. Can anyone think of something?
|
|
|
|
|
Hi,
your code looks fine. If anything is slow, it must be the piece you did not show nor discuss,
i.e. GetAvgPixelVal()
It is my guess you are enumerating all pixels there, which is bound to be very slow or slow,
depending on how you do it. If you want more help, show that code too, and please provide an estimate
to the image size.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Friday, June 10, 2011 11:30 PM
|
|
|
|
|
Thanks for the reply. It doesn't run slow (actually it runs very fast), I just wanted to know if there is a more efficient way to do it. I am building a program that makes a picture mosaic from a given directory of images, which can be made from thousand images with different sizes.
I don't believe that I can improve GetAvgPixelVal() and it runs quite fast. The code for it is this:
unsafe private Color GetAvgPixelVal(Bitmap bmp)
{
Color RetVal;
int r = 0;
int g = 0;
int b = 0;
int nWidth = bmp.Width;
int nHeight = bmp.Height;
BitmapData data = bmp.LockBits(new Rectangle(0, 0,
nWidth, nHeight), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
int remain = data.Stride - data.Width * 3;
byte* ptr = (byte*)data.Scan0;
for (int i = 0; i < nHeight; i++)
{
for (int j = 0; j < nWidth; j++)
{
b += ptr[0];
g += ptr[1];
r += ptr[2];
ptr += 3;
}
ptr += remain;
}
bmp.UnlockBits(data);
RetVal = Color.FromArgb(r / (nWidth * nHeight), g / (nWidth * nHeight), b / (nWidth * nHeight));
return (RetVal);
}
|
|
|
|
|
Hi,
performance wise that code is perfect.
BTW: I assume your original code (with bmp and bmp2) sits inside a loop; if you no longer need the bmp (i.e. before you assign the next image to it, you should call Dispose(), that will release its memory sooner and improve your apps overall performance.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Friday, June 10, 2011 11:30 PM
|
|
|
|
|
I'm already doing it
Thank you for the reply.
|
|
|
|
|
Not sure if you can use this idea, but some image formats (like TIFF) allow compression. Using compressed images will reduce the time it takes to read/write them from/to disk files.
Generally it takes more time to transfer an image to/from disk than to process it, so if you can compress the images the process will be faster.
|
|
|
|
|
The only problem is that I don't have any control in selecting what images the program would use. If I could control it i would make all the pictures JPEG 100*100 and save time in reading and resizing them...
|
|
|
|
|
I have developed a game in C# and i want to convert it to a executable file.
|
|
|
|
|
Did you try compiling the code? In your IDE there should be an option somewhere to build the project / solution. Although to be honest you should know that already.
Unless of course, your not using an IDE. In which case, go and get SharpDevelop or something, create a project and add your code, then click 'Build -> Build Solution' or press F8.
My current favourite word is: Delicious!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
why not just change the extension from .cs to .exe? that results in an exe file, doesn't it?
BTW: Visual Studio C# Express is downloadable for free and it works well.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
I have a plugin system, currently using interfaces, and I want to switch over to abstract classes, for the hybrid approach. The setup is that I have my plugin class based off of a chain of abstract classes (base class in the plugin framework, then a class in my app to separate various plugin types). My problem is, while trying to instantiate the class using reflection, I want to compare the classes against the original base type (the one at the start of the chain, within the framework) as the manager uses generics.
Here's a diagram:
(Embedded Framework [Class]) < (Application [Definitive A.Class1] < [Definitive A.Class2]) < (Plugin [MyClass])
I need a way to check if MyClass is a Class.
I may have just answered my question. maybe if (MyClass is Class){}?
|
|
|
|
|
So long as MyClass at some point inherited from Class , then your if statement should return true .
So yeah, I guess you did answer your question!
My current favourite word is: Delicious!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
Bah, didn't work. I get the error The given expression is never of the provided type (CS0184). Here is the context:
private void TryLoadingPlugin(string filename)<br />
{<br />
try<br />
{<br />
FileInfo file = new FileInfo(filename);<br />
filename = file.Name.Remove(<br />
file.Name.Length - file.Extension.Length,<br />
file.Extension.Length);
Assembly asm = AppDomain.CurrentDomain.Load(filename);<br />
foreach(Type t in asm.GetTypes())<br />
{<br />
if (t is BasePlugin)<br />
{<br />
if( !t.IsInterface && !t.IsAbstract)<br />
{<br />
FoundPlugins.Add(t);<br />
break; <br />
}<br />
}<br />
}<br />
}<br />
catch(Exception e){throw e;}<br />
}
Drat, inline code removes tabs
|
|
|
|
|
I see. Well, this ain't gonna be too pretty and there is probably a better way but this is all I can think of:
foreach(Type t in asm.GetTypes())
{
Type baseType = t.BaseType;
while(baseType.BaseType != typeof(System.Object))
{
baseType = baseType.BaseType;
}
if (baseType == typeof(BasePlugin))
{
if( !t.IsInterface && !t.IsAbstract)
{
FoundPlugins.Add(t);
break;
}
}
}
Oh yeah, < pre > tags keep the indentation.
Using is only works when you have an instance of the class your checking, shame really.
My current favourite word is: Delicious!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
Hey, seems to have worked! I tweaked it a bit, in case Object isn't the base-base class. As this is a framework, you never know
foreach(Type t in asm.GetTypes())
{
Type baseType = t.BaseType;
bool Complete = false;
while(!Complete)
{
if (baseType == typeof(BasePlugin))
{
if( !t.IsInterface && !t.IsAbstract)
{
FoundPlugins.Add(t);
Complete = true;
break;
}
}
else if (baseType == typeof(System.Object))
Complete = true;
else
baseType = baseType.BaseType;
}
}
|
|
|
|
|
Hi Guys and Gals,
I have my c# win form app connected up to a sql compact db.
I have a form which contains fields to enter company data, ie an address.
Now at the moment when I open that form, I do a read to see if a record exists...
xDataSourceAccess = AppSet.DataSourceAccess;
conn = new SqlCeConnection(Properties.Settings.Default.CS_Account + xDataSourceAccess);
string strRecordExisit = "SELECT OID from tbl_CompanyDetails";
conn.Open();
cmd = new SqlCeCommand(strRecordExisit,conn);
Reader = cmd.ExecuteReader();
if (Reader.Read())
xRecordFound = true;
Reader.Close();
etc....
Is this the the best way to check to see if a record exists? (ie best performance and memory usage)
thanks
|
|
|
|
|
Yep, pretty much. Any other methods you use are going to boil down to the same technique. Though, I'd probably have a stored procedure that checks for the existance and passes back a True/False, or a record count if there is more than one record your checking for in the same table.
|
|
|
|
|
IIRC you can't use stored procedures in SQL Compact.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Hmmm...didn't know that. I've never used it before, having gone only as low as Express. Just goes to show you what "assume" really stands for!
|
|
|
|
|
Hi,
I am developing an application in a Pocket PC using .NET Compact Framework 3.5 with C#..
Can anyone tell me what are the toolkit i need to install to run my application in Pocket PC to convert my voice based commands into text..?
And also let me know what are the classes and libraries i need to use to do the above..
Thanks in advance..
|
|
|
|
|