|
|
You don't need to load any namespace unless you want to load all types within a namespace.
E.g.
var q = from t in a.GetTypes()
where t.IsClass && t.Namespace == "ChipReader"
select t;
Reflection is a performance-intensive way to achieve late binding.
Unless you are studying reflection, you might also want to consider Interfaces as another means to achieve late binding.
As another example. an object is late bound when it is assigned to a variable declared to be of type Object .
|
|
|
|
|
I agree with Luc, you are better off doing the following:
class Executable {
public int ReadChip()
{
byte[] data = new byte[32];
Assembly a = Assembly.LoadFrom("Reader.dll");
Type mm = a.GetType("ChipReader.Reader");
IReader reader = (IReader)Activator.CreateInstance(mm);
int status = reader.ReadChip(data);
}
}
Somewhere both the reader DLL and the main app can reference*:
interface IReader {
int ReadChip(byte[] data);
}
DLL:
namespace ChipReader {
class Reader : IReader {
public int ReadChip(byte[] data){
}
}
}
This allows you to call methods on the reader directly without messing about with reflection code, apart from looking up and instantiating the original type. You can then pass the IReader instance around in the executable like any normal object.
*: If the reader DLLs are specific to this application, the interface can just be in the application, and the reader assembly would need to be compiled with a reference to the executable. This is typically a good approach for plugins, where they are plugging in to a known application. Otherwise, it needs to be in a separate interface assembly which both the app and the reader DLL should reference.
|
|
|
|
|
Ok I'll give this a shot. It does looks more simplier than what I do.
|
|
|
|
|
i have created my own media player in wpf.i want to add
repeat and shuffle button like same as VLC player, but there is problem in syncronization between them and
secondly i want to add control like media library
in widows media player how can i do it ????
|
|
|
|
|
If you can use the XNA framework (Microsoft.Xna.Framework.Media ), try with the MediaLibrary class[^].
|
|
|
|
|
hey i want just code for scaning a folder through which i can use it sub folder and i directly add this to my media player.....i m using wpf ....just feature like windows media player\ FIle \manage library and we can add song to our library
|
|
|
|
|
|
When we install the Windows application setup file then it is giving different results.
If I install in Windows XP it is copying the files in the path C\Programme Files\Application. In XP application is working without any issues in all machines.
But if I install same setup in Win7 then it is copying in the C\Programme Files\ only.All the files are placed in C:\Programe files and application is not working.
If I copy individual files and paste inside the C:\Programme Files\Application then again it started working.
Request you to help me in resolving this issue.
Thanks in advance.
|
|
|
|
|
You already posted this question here[^]; please use one forum only.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Hi,
i am trying to create for a given array two new arrays which are then used as tolerance-lines for limit-check.
This should run in three steps
1. The first function captures a waveform (from a scope) of a good part - this is what i already have.
IN: -
Out: double[] Waveform
2. Then the second function gets this “good” waveform plus two Delta-values and should create two output-tolerance-arrays
IN: double[] Waveform
int Delta-X
double Delta-Y
OUT: double[] UpperLimitLine
double[] LowerLimitLine
3. Now I capture again a waveform of a new part and compare its waveform against the two tolerance-arrays that were previously created.
IN: double[] Waveform
double[] UpperLimitLine
double[] LowerLimitLine
OUT: bool Result (is True if Waveform is between the limits)
If I only do a simple + and – for each point in the first array then this of course also generates two limit-lines BUT if there is a very small peak in the array then this is not working any more.
Imagine we have a measurement of 1000 points which is always 0 – only at point 500 the value is 10.
This means now that all other measurements also must have the peak at exactly point 500 to pass the tolerance-check.
This is why I need to have two delta-values to make the limit-array also wider to the left and right side and not only up and down.
The problem is: How can i do this with C#?
Thanks for all help
|
|
|
|
|
Hi,
this isn't a C# question, it is more of a conceptual question. This might work for you, it is looking at a couple of the neighbouring points (it is pseudo-code, not C#!):
define a bell-like shape over a small interval with a maximum of 1, say:
bell[-3]=0.1;
bell[-2]=0.3;
bell[-1]=0.5;
bell[ 0]=1.0;
bell[+1]=0.5;
bell[+2]=0.3;
bell[+3]=0.1;
now calculate the upper bound:
foreach(int x in xRange) {
max[x]=good[x];
foreach(int i in bellRange) {
int y=good[x+i]+yDelta*bell[i];
if (y>max[x]) max[x]=y;
}
}
and simimlar for lower-bound.
Luc Pattyn [My Articles] Nil Volentibus Arduum
Fed up by FireFox memory leaks I switched to Opera and now CP doesn't perform its paste magic, so links will not be offered. Sorry.
|
|
|
|
|
Can anyone help me out in Converting a xls file which is given as i\p to a .xml file and back to .xls.
|
|
|
|
|
Here[^] is a starter article on reading Excel files. You can create your XML by using an XmlWriter[^] or XmlTextWriter[^]. Going back the other way is just a reverse of these processes.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
|
Hi all,
I have a C# application that uses vpc.dll. The application works without problems when running in VS. I have added a reference to the vpc.dll which reisdes in the project location (the same path as the .exe).
However, when I install the application on a client machine (using SetupProject in VS where I have included the vpc.dll to the application folder) the call to vpc.dll fails. Basically it will not run at all.
I'm fairly new to computer programming, but I find it strange that it works inside VS, but not when installed on client machine.
Thanks for any pointers!
|
|
|
|
|
If this is a COM dll, you will need to register it on the client machine.
Include the registration process in the setup install program.
|
|
|
|
|
Hi,
I have tried to register the .dll but I get an error message like "DllRegister" was not found, not a valid DLL or OCX file.... Not sure what this means but I've tried this both on the development machine and on the client machine.
|
|
|
|
|
You said you set a reference to this .DLL?? That means it's COM-based.
But now you're saying that if you execute "REGSVR32 vpc.dll" it complains that it can't find DllRegister. That means it's NOT COM-based.
I get the feeling you didn't set a reference to it because what you're saying is contradictory to itself.
|
|
|
|
|
I get the feeling (having tried to find out what vpc.dll was) that he's followed these[^] steps, so it's the wrapper for the COM client.
|
|
|
|
|
|
Kaare Tragethon wrote: the call to vpc.dll fails. Basically it will not run at all.
My suspicion is that you are missing something that vpc.dll is dependent on. Is this Virtual PC that you are trying to run?
|
|
|
|
|
You are correct, it is VirtualPC. I've "extracted" a .dll from the vpc.exe file (using tlbimp vpc.exe /out vpc.dll).
I've tried searching google A LOT, but there's very little (or no) documentation on this that I can find.... The only thing I could find was the above "extract" method....
Thanks!
|
|
|
|
|
Right - chances are then that the actual Virtual PC client isn't installed on the end users machine. Basically, your DLL is a wrapper for the COM calls - it's not a COM component so you don't need to register it, but it does need the actual COM object registered; in this case Virtual PC.
|
|
|
|
|
I see, thanks for the help!!
|
|
|
|