|
There's a thread on SO[^] that talks about sharing stuff between projects.
You'd typically put the shared functionality in a project, and reference that (and invoke it) from your addin-project.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
|
Richard/Team,
Accept my apologies, as I was not sure of the correct forum, i have posted 3 forums...thanks
|
|
|
|
|
What about the one called Visual Studio?
Veni, vidi, abiit domum
|
|
|
|
|
I am sorry, can you come again.
|
|
|
|
|
I am trying to start with serial port communication using C# for my project. So even though i am familiar with the C# language i am new into I/O Port communication and i seem to be having some problem with my code
using System;
using System.IO.Ports;
class Program
{
public static void Main ()
{
string portName = @"\\.\COM10";
_serialPort = new SerialPort (portName);
_serialPort.Close ();
}
}
i am getting an error :
Error 1 The name '_serialPort' does not exist in the current context c:\users\alfie\documents\visual studio 2012\Projects\serial\serial\Serial_port.cs
Someone pls help me get started with this. .
Also i have tested with the following code and verified that the COM10 port is working and is of type "char"
class Program
{
static void Main (string[] args)
{
string portName = @"\\.\COM10";
IntPtr handle = CreateFile (portName, 0, 0, IntPtr.Zero, 3, 0x80, IntPtr.Zero);
if(handle == (IntPtr) (-1))
{
Console.WriteLine ("Could not open " + portName + ": " + new Win32Exception ().Message);
Console.ReadKey ();
return;
}
FileType type = GetFileType (handle);
Console.WriteLine ("File " + portName + " reports its type as: " + type);
Console.ReadKey ();
}
[DllImport ("kernel32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall, SetLastError = true)]
public static extern IntPtr CreateFile (string lpFileName, uint dwDesiredAccess, uint dwShareMode, IntPtr SecurityAttributes, uint dwCreationDisposition, uint dwFlagsAndAttributes, IntPtr hTemplateFile);
[DllImport ("kernel32.dll")]
static extern FileType GetFileType (IntPtr hFile);
enum FileType : uint
{
UNKNOWN = 0x0000,
DISK = 0x0001,
CHAR = 0x0002,
PIPE = 0x0003,
REMOTE = 0x8000,
}
}
|
|
|
|
|
The error message you are getting is telling us that you are using a variable called "_serialPort" but it is never defined. There needs to be a definition of that variable somewhere. Something like:
SerialPort _serialPort;
BDF
The internet makes dumb people dumber and clever people cleverer.
-- PaulowniaK
|
|
|
|
|
Thanx... That worked like a charm...
Sorry for my silly question....
|
|
|
|
|
Well, you could start by declaring the variable...
using System;
using System.IO.Ports;
class Program
{
private SerialPort _serialPort = null;
public static void Main ()
{
string portName = @"\\.\COM10";
_serialPort = new SerialPort (portName);
_serialPort.Close ();
}
}
The only instant messaging I do involves my middle finger.
|
|
|
|
|
OriginalGriff wrote: using System;
using System.IO.Ports;
class Program
{
private SerialPort _serialPort = null; public static void Main ()
{
string portName = @"\\.\COM10";
_serialPort = new SerialPort (portName);
_serialPort.Close ();
}
}
I tried this code... but i am getting this error...
An object reference is required for the non-static field, method, or property 'Program._serialPort'
|
|
|
|
|
Sorry, my bad!
I forgot that Main is a static method!
Add the word "static" between "private" and "SerialPort"
The only instant messaging I do involves my middle finger.
|
|
|
|
|
thanx.... that did the trick...
|
|
|
|
|
You're welcome!
The only instant messaging I do involves my middle finger.
|
|
|
|
|
|
If you look at the OP, there are two sections of code: the first using SerialPort is the one he has problems with, and the second is labeled as a test to prove the serial port works.
The only instant messaging I do involves my middle finger.
|
|
|
|
|
how can Read/write directly to a specific sector in a hard disk
with c#
Please help me if anybody know
|
|
|
|
|
|
Hi
I Saw this sample but it doesnt tell how can i write in sector, this sample just show total size of sector in disk
|
|
|
|
|
It shows how to read from the disk, so it should not be too difficult to figure out from that how to write to it.
Veni, vidi, abiit domum
|
|
|
|
|
rd.Read();
if (rd["allwid"].ToString() == "")
{
allwdet.Allowanceid = 1;
rd.Close();
}
else
{
allwdet.Allowanceid = int.Parse(rd["allwid"].ToString()) + 1;
rd.Close();
}
}
|
|
|
|
|
One doesn't modify generated code; if something is wrong, you'd fix it in the model you're generating from.
As for the output; I'd imagine the first record to not have a value for it's allwid-column, and values 12 and 13 for records 2 and 3. What was your expected result? And what are the actual values in the database?
Offtopic; It'd be nice if the subject-line of your post contained the subject - not a complete question. That goes in the post itself.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Troubleshooting the query might help find solve the problem.
|
|
|
|
|
what is the concept of teamviewer??
Can anyone just tell me what is the concept behind teamviewer???
I just need a simple concept to start....
Please someone help me in it...
|
|
|
|
|
The first page of a google search lead me to this[^] blog page.
|
|
|
|
|
I have a database that houses (amongst other things) data on defects and repairs, car repairs as an example. The way this db breaks down is this:
Table Defect holds the information about the defect (Damaged bumper, broken windshield, w/e)
Table Material holds information about materials used to repair (ex: new bumper)
Table Equipment holds information about equipment used to repair (ex: buffer)
Table Trade holds information about who is responsible for the repair and their wage (ex: mechanic)
There are three many to many tables that join defect with trade/eq/mat and have a quantity.
Long story short, I have a Scalar value UDF that returns the value of all of these costs together divided by a value in the defect table.
I decided to try to simplify it into a query (The simplification discussion is a TSQL issue outside the scope of this post) and in doing so had to ask myself, does this belong as a SQL query or should I write it as an additional property of the model in c#?
I could just as easily write a partial class that handles all of this craziness on the web server side. Is this all pedantic? Is it really a question of db server performance vs web server performance? I have read that scalar value functions in TSQL can be low performing due to threading issues, which is what sparked this thing in the first place.
Thoughts? Opinions?
Cheers, --EA
|
|
|
|