|
0) Avoid float ; try Decimal or double
1) Avoid Convert ; in this case use ToString , perhaps with a format parameter
2) Avoid TextBox for numeric values; use a NumericUpDown
|
|
|
|
|
A project with an output type of class library cannot be started directly.In order to debug this project, add an executable project to this solution which references the library project. Set the executable project as the startup project.
While running the program in C# visual studio 2010 I am getting this error...! please tell me how to sort out this error..!
Thanks.
Regards
|
|
|
|
|
You need an executable that calls into that DLL appropriately. If you haven't got one, you have to write on. If you have got one and it's in the same solution, right click on the project name for that executable and select "Set as StartUp project" from the context menu.
|
|
|
|
|
Thank you
|
|
|
|
|
|
Since I am new to working a C# 2010 desktop application, I have the following questions to ask about how to accomplish the following tasks:
1. I would like to use linq to sql on a sql server 2008 r2 database to pull all the data from one column in one particular table. The value for the one array would be varchar(50) There will be more than one row selected at the time. (What I have seen of linq so far is to pull only one value by using singleordefault.)
2. I then would like to take the values obtained from step number one and load those values into array,collection, or some type of similar object.
Can tell me how to accomplisth this goal and/or point me to a reference that I can use?
|
|
|
|
|
classy_dog wrote: (What I have seen of linq so far is to pull only one value by using
singleordefault.)
There are many operations, such as Take(n) to take n rows, or ToList() to write to a generic List.
|
|
|
|
|
There is also a method ToArray() to return an array instead of a list. One of the advantages of both ToArray and ToList is that it forces immediate execution, instead of the default defered of LINQ. In addition to Take method, there is a Skip method
|
|
|
|
|
Hi
i have a fileupload control in form, and now i want to check the size of file before upload it. i wrote this code but the value of fileSize = 0 all the time. what should i do. can anybody help me?
int fileSize = fuSignature.PostedFile.ContentLength
|
|
|
|
|
ptvce wrote: before upload
You code seems to be the server-side code and will be executed AFTER the file is uploaded. To check the file size before uploading the file, you've to use client side code i.e. JavaScript. But JavaScript does not allow accessing file system due to security reasons. Here[^] is an inelegant approach to do this if you are targeting only IE.
|
|
|
|
|
That code doesn't work because ASP.NET is a server side technology. In other words, you have to transfer the posted file to the server before it can work out how big it is. There are things that you can do, but they generally involve compromises - one trick is to use a flash uploader control which can get access to the users hard disk to retrieve this information. Alternatively, if you know that your clients aren't going to be using Internet Explorer, you can use this function:
<script type='text/javascript'>
function showFileSize() {
var input, file;
if (typeof window.FileReader !== 'function') {
alert('The file API isn't supported by your browser');
return;
}
input = document.getElementById('fileinput'); // Or whatever name your input control is...
if (!input) {
alert('You don't seem to have a file input control');
return;
}
if (!input.files) {
alert('This browser doesn't seem to support files.');
return;
}
if (!input.files[0]) {
alert('You havent picked a file');
return;
}
file = input.files[0];
alert("The file is " + file.size + " bytes");
</script> If your clients have IE, you may have to use an ActiveX control.
A final note - you really should have posted this in the ASP.NET forum.
|
|
|
|
|
I have developed a C# .Net 3.5 Windows service application that works perfectly fine when I run it in Visual Studio, however when I try to install it on a Windows 2008 R2 64-bit server, it fails to start.
The only error that is shown is:
A system error has occurred.
System error 1067 has occurred.
The process terminated unexpectedly.
No more information, nothing at all in the event log. There is no Com+ or similar, just a plain service. (Also tried to remove all logic from the service with no luck).
I've tried to compile all parts with "AnyCPU" and 64-bit without luck. I've tried both the 32-bit and 64-bit installutil.
If I copy the entire folder to a Win7 machine (64bit) and install it in the exact same way, it works like it should.
Any ideas at all on how to resolve this? I'm pretty much out of ideas and without any logs whatsoever, it's hard to find out what it could be.
|
|
|
|
|
Add some logging to your program. You could use a common logging framework like log4net. Good places to start with are the constructor of your service and the OnStart method. You'll see then how far the initialization runs on that machine, and can get an idea about what went wrong.
|
|
|
|
|
We are using logging (log4net) but nothing was logged. But I added some logging points and found out that it is the dynamic loading of an external dll that fails.
(Activator.CreateInstance)
ERROR!! Assemblyladdningsfel! Exception has been thrown by the target of an invocation.
ERROR!! Exception has been thrown by the target of an invocation.ERROR!! The type initializer for
Don't know why yet, but probably due to some stupid 2008 security control.
|
|
|
|
|
No, surely not "MyExternalDll", but the constructor of a class therein. Look again at the original message!
|
|
|
|
|
Depends on what your code is trying to do. There could be a security exception and an unhandled exception might stop the service. It is very difficult to guess without seeing your code.
|
|
|
|
|
Daniel Jansson wrote: If I copy the entire folder to a Win7 machine (64bit) and install it in the
exact same way, it works like it should.
Incorrect process.
1. Install it on the Win 7 machine
2. Install it on Win 2008
3. Delete the files from Win 7
4. Copy the files as installed from Win 2008 to Win 7.
5. See if it runs.
If it doesn't compare files.
Daniel Jansson wrote: Any ideas at all on how to resolve this?
Presuming the install works then it means it is an environment problem.
First change the user that the service runs under to you. Try to run it.
If that doesn't work then open permissions up completely on the install dir. If that doesn't fix it then restore then and continue.
Next step is to determine if it is a start up problem or a code problem. You might be able to determine this by adding a log line as the very first line of the Startup (Service method itself). If that gets into the log then you know that some other process is falling. You can debut that by putting a try/catch in Startup, which you should have anyways and log it. This doesn't work if you start threads and you will need to add more logging for exceptions in threads (which you should also be doing any ways.)
If the first log line doesn't show up then it becomes more difficult because it means that the service class is attempting to pull in a dll and initialization for that fails. Resolving that is done by creating a proxy in the Service which uses dynamic loading of everything else. Basically clone all the real functionality in the Service class, remove the functionality from the service class, then use dynamic loading to load and execute the second class with appropriate exception handling and logging for that.
Of course the above assumes that logging itself isn't the problem.
|
|
|
|
|
I am looking for a C# Class which talks to a Biometric device which is connected to the PC and then captures the finger print image. A generic solution which is not dependent on any third part software is what I am looking at.
A little about the solution I am working on its win forms application which displays the captured finger print image and also stores the same as an image.
|
|
|
|
|
.NET Framework does not provide any built-in API to work with Biometric devices. The only way to do this is using the API provided by the Biometric device vendor. Check if you vendor has an API library that is .NET compatible and start using it.
|
|
|
|
|
If you are developing for windows 7 and the biometric device is recognized by windows (control panel - biometric devices) then a starting point would be this blog post of Thomas Lebrun : Link.
|
|
|
|
|
Hello all,
I want to disable click event of picture box. Means click on the picture box not fire.
How i do this?
With Regards
Sanjeev
|
|
|
|
|
Simple. Don't hook up the event to an event handler.
|
|
|
|
|
If you want to unsubscribe after previous subscription to the event, just use -= :
yourPictureBox.Click -= YourMethod;
|
|
|
|
|
I have been scouring the net looking for updated information on interfacing a C# applilcation to a MIDI control interface (M-Audio Xponent). The best I could come up with is PureMidi, Midi-dot-net, and MIDI out setter here on codeplex. Unfortunately, I need the raw information, and need to strip out hundreds of lines of code to make it work. I can get the input and output devices fine, but I need to send simple MidiOutshortmsg and MidiOutLongMsg (sysex), and recieve MidiInshortMsgs. None of the examples really touch on long messages, and all color the short into actual deciphered note info that I don't want. The examples are much too complex for my needs. I need something very simple without 10 support files full of nonsence to sift through and strip down. Most everything is also for vc2005 or before, and are in dreadful need up update to VC2010/2012. The Midi toolkit is useless to me. It won't compile,and I can't determine why. I've spent the last week looking, and the 3 examples provided are the best usefull examples I've found to date, but are much too complex as stated. Please help, I'm beyond frustrated. All I need are simple examples to send and recieve raw hex data. I can parse it from there.
Thanks for any assistance you can provide.
Jeff
|
|
|
|
|
Hi Jeff,
midiOutShortMsg is quite simple, midiOutLongMsg is more complex due to the way that the MIDIHDR structure is used.
Receiving SysEx can be tricky as you will need to add and control the receive buffers.
I can help you with this but I don't think I'll have time until around this time tomorrow unfortunately. If you haven't marked this as solved by then I'll dig out some code to assist.
In the meantime, for output you're going to need these functions:
midiOutGetNumDevs
midiOutProc (this will be a delegate in C#)
midiOutOpen
midiOutShortMsg
midiOutPrepareHeader
midiOutLongMsg
midiOutUnprepareHeader
midiOutClose
and these structs
MIDIOUTCAPS
MIDIHDR
You will find all the definitions for these on MSDN. They are shown in C++. You will need to create PInvoke versions (to call into Winmm.dll) of these in C#. Search your system for MMSystem.h as there are many things in there (such as the values for constants used etc) that will be handy.
Edit: 20 hrs and no other answers, give me 8 to get some sleep (UK) and I'll post some working code and pointers. Do you have a link to the MIDI implementation chart for the device you're trying to communicate with?
modified 6-Sep-12 19:39pm.
|
|
|
|