|
Does the exception occur inside the fnMGetApnData() function? If so you need to track exactly what is going on in there, and without seeing the code it is impossible for anyone here to make a guess.
The best things in life are not things.
|
|
|
|
|
Yes, fnMGetApnData() is the unmanaged call to the dll. I don't have the source code to this dll. I tried to debug this unmanaged call in the assembler code but have not enought assembler experience. The only thing I can see is that a assembler "call" is causing the exception.
|
|
|
|
|
marca292 wrote: I don't have the source code to this dll
It's unlikely that anyone here will be able to guess what's going on. Is there any way you can get hold of the people who created the dll?
The best things in life are not things.
|
|
|
|
|
I was just wondering if anyone could see something wrong with my C# struct declaration that could cause this error.
Maybe, I shall see if I can get hold of the people who created this dll.
|
|
|
|
|
Make sure wchar_t is what you think it is. I don't see anything obviously wrong with the structure definitions.
Alternatively, does the function rely on the path being set to zeros? You are doing that in C++ and not C#. You might need to assign "\0" to path.strPath if the C function expects it to be set to zero length to start with. (I'm not sure what the marshalling does with an unassigned string variable in a struct. You might need to assign a value to all the string properties; a constructor or method on the struct to do that might be a good idea.)
|
|
|
|
|
Try changing the CharSet to CharSet.Ansi.
|
|
|
|
|
I'm confused as to why you're using the UnmanagedFunctionPointerAttribute to get the dll function and then go through all that marshalling mess. Wasn't a simple DllImport enough?
|
|
|
|
|
please send me code to run the project in asp .net
thanks
|
|
|
|
|
Arvind Vishwakarma wrote: please send me code to run the project in asp .net
What sort of question is that? Please note:
- This is not the ASP.NET forum
- You have not given any details about what problem you are trying to solve
- Working projects are not free, you either have to buy them or build them yourself
The best things in life are not things.
|
|
|
|
|
|
hey! be more specific while asking question and please don't ask to send me code because no one will send you code whatever
Try
ASP.NET - Database Connection[^]
|
|
|
|
|
How about doing a search on the internet for this information?
You could check out msdn for tutorials / quickstarts.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
Hi,
i'm not sure how to describe my self (not sure what is the name of this issue)
i can write to console like this
Console.WriteLine("The answer of {0} + {1} is {2}",2,2,2+2);
how exactly this topic (of {0}... and the arguments) is called ?
any way, i was wondering if i can write something like this.
Dictionary <string,int> dic = new ...
string [] arr = {"hello","world"};
foreach (var str in arr)
{
dic.Add({0},str, str.Length);
}
I know that it's not the correct syntax, but i hope i was understandable enough...
|
|
|
|
|
Uh, no, I have no idea what you want, but would String.Format help?
|
|
|
|
|
The method has to support Composite Formatting[^] to use that syntax.
You can build the string first, perhaps using StringBuilder, String.Format(), string operators, etc., before adding it to the dictionary.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
If you want to write a function that accepts variable number of arguments like WriteLine does, you have to uses the params modifier.
http://msdn.microsoft.com/en-us/library/w5zay9db(v=VS.100).aspx[^]
In the format string {#} where # is a number refer to the the argument at that position starting at index 0 with the first argument after the format string.
Philippe Mori
|
|
|
|
|
Your sample doesn't really make any sense.
Why don't you just do it this way:
for (int i = 0; i < arr.Length; i++)
{
dic.Add(arr[i], arr.length);
}
One of the Console.WriteLine method overloads acts just like string.Format . You pass a format string, followed by an array of objects. The number inside the curly braces indicates the index into the specified object array. Just like all other arrays, this one is 0 based, and you can't specify a value < 0 or > the number of elements in the array (minus 1). You can specify the same array index over and over again:
WriteLine("{0}{0}{0}", "x", "y");
which would result in "xxx" being written
or even out of order:
WriteLine("{2}{1}{0}", "x", "y", "z");
which would result in "zyx" being written.
You can have more objects to format, but your indexes in the format string can never exceed the number of objects in the array.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
String.Format() does the trick, Console.WriteLine() internally uses String.Format() .
|
|
|
|
|
I'm unable to get ms access afterupdate event like functionality in c# textbox.
What I have done so far is:
private void VocNoTextBox_KeyDown(object sender, KeyEventArgs e)<br />
{<br />
if (e.KeyData.Equals(Keys.Enter))<br />
MoveToSpecificVocNo();<br />
}<br />
and Leave event
<br />
private void VocNoTextBox_Leave(object sender, EventArgs e)<br />
{<br />
MoveToSpecificVocNo();<br />
}<br />
But the problem is If I press enter and press tab to move to next field. The event is called twice. One for Enter key, another for Leave.
Is there any solution?
Regards
Asif Rehman
|
|
|
|
|
One way would be using a flag to indicate it had been run already.
At the form level:
private bool func_called = false;
In KeyDown you set it to true after calling the function:
private void VocNoTextBox_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData.Equals(Keys.Enter))
{
MoveToSpecificVocNo();
func_called = true;
}
}
And in Leave you reset it (if this is appropriate for what it does):
private void VocNoTextBox_Leave(object sender, EventArgs e)
{
if ( !func_called )
{
MoveToSpecificVocNo();
}
func_called = false;
}
Jack of all trades ~ Master of none.
|
|
|
|
|
Possibly a better way (depends on what MoveToSpecificVocNo() does) is to implement the SendKeys class:
private void VocNoTextBox_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData.Equals(Keys.Enter))
{
SendKeys.Send ( "\t" );
}
}
This will cause the focus to jump and trigger the Leave event.
Jack of all trades ~ Master of none.
|
|
|
|
|
Hi
This is a question in File Type forensic identification - how can I verify, via C#, an Excel file really is an Excel file, a Word file is word, a 7z/zip is genuinely a zip file, a csv is what it claims to be?
Thanks
dev
|
|
|
|
|
For each type of file, the validation would be different. Thus it cannot be done in a generic way.
Many file types do have a signature that could be checked (http://www.garykessler.net/library/file_sigs.html[^]).
Also so file format are based on other file format like an xlsx file is based on a zip file with some specific content.
Also for some file type some statistics could be used... or some patterns could be found in the file.
Generally, you won't really validate a file... You will try to open it using appropriate library and assumes the file is good if it can be opened and used.
Some file might also have a checksum to validate it or might contain information related to its length. A wave file for example would have the number of sample (or something like that) in it header. That information with other information like the number of channel and the bit depth would allows to validate that the length of the file match (maybe rounded up a bit) with that value.
Philippe Mori
|
|
|
|
|
Yeah, just open it in the appropriate app and let it tell you, it's the expert.
It's really not worth trying to guess.
|
|
|
|
|
Hi. I have a problem which i am stuck in badly.
Scenario:
I have a abstract class named "VisaOscilloscope" defining some abstract methods and properties, which some driver utility classes inherit and implement the actual external hardware driver functionality.e.g. i am giving a shorter version of the class below.
public abstract class VisaOscilloscope : Oscilloscope
{
[Category("IviScopeBase Capability Group")]
[DefaultValueAttribute(0)]
[DescriptionAttribute("Specifies the location of the center of the range that the Vertical Range attribute specifies. The value is with respect to ground and is in volts")]
public abstract double VerticalOffset { get; set; }
[Category("IviScopeBase Capability Group")]
[DefaultValueAttribute(0)]
[DescriptionAttribute("Specifies the absolute value of the full-scale input range for a channel. The units are volts")]
public abstract double VerticalRange { get; set; }
[Category("IviScopeProbeAutoSense Extension Group")]
[DefaultValueAttribute(false)]
[DescriptionAttribute("If this attribute is True, the driver configures the oscilloscope to sense the attenuation of the probe automatically. If this attribute is False, the driver disables the automatic probe sense and configures the oscilloscope to use the value of the Probe Attenuation attribute")]
public abstract bool ProbeAttenuationAuto { get; set; }
public abstract void init();
public abstract void activate();
public abstract void acquire();
public abstract float[] collect();
public abstract void close();
Now a utility class that has to inherit from this base class and implement the properties and methods by connecting to a pre-written driver. e.g.
class TK_TDS1012B : VisaOscilloscope
{
public override double VerticalOffset
{
get
{
return myTk.GetDouble(tktds1k2kProperties.VerticalOffset);
}
set
{
throw new NotImplementedException();
}
}
public override double VerticalRange
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
public override bool ProbeAttenuationAuto
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
public override void init()
{
throw new NotImplementedException();
}
public override void activate()
{
throw new NotImplementedException();
}
public override void acquire()
{
throw new NotImplementedException();
}
public override float[] collect()
{
throw new NotImplementedException();
}
public override void close()
{
throw new NotImplementedException();
}
}
So the problem is i want to group some properties into a list as they can duplicated. e.g. Oscilloscope have some base properties valid for all channels like waveform acquisition, but some are specific to each channel and there can be many number of channels. like each channel has vertical range, attenuation etc.
So what i want is list of abstract properties in the base class which can be implemented in the inherited classes. I can only access the driver in the inherited classes as there are many different drivers to connect to and all are of visa type.
So what i can't figure out is how to add a list of properties to the base class of which everything is to be implemented and populated in the inherited classes.
Any help please I would be really thankful.
|
|
|
|