|
Heath Stewart wrote:
singleton pattern
I'm sorry, but I don't know what that is
Heath Stewart wrote:
Just put the classes in an assembly...
So you do suggest classes instead of structs? I read in an article on CodeProject before by Nishant that whenever you find that you're using a class merely to store values, it's better to use a struct. Comments?
Sammy
"A good friend, is like a good book: the inside is better than the cover..."
|
|
|
|
|
A singleton is a single instance of an object. You can either use a simple approach like:
public sealed class MySingleton
{
private static MySingleton instance;
private int i;
private MySingleton()
{
i = 1;
}
public static MySingleton Instance
{
get
{
if (instance == null)
lock (typeof(MySingleton))
if (instance == null)
instance = new MySingleton();
return instance;
}
}
public static int SomeMethod()
{
return Instance.i;
}
} Or you could use a ContextBoundObject with its own RealProxy derivative that returns the same instance when someone tries to instantiate your object.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
please some one tell i have a barcode scan device and i wanna to write a code using c# to get the barcode from the barecode device
i will make that by making a thread in my code to detect any input from the barecode then:
_how to make that connection between my code and the barecode device so that user can input the serial of any product from the keyboard (by manualy focusing at text box) or from the barecode device (without focusing at any thing)
please some one can help me in that senaro i wanna just an overview idea about how to make that way of code
::::tonaxxl:::::
|
|
|
|
|
You already asked this question and got the answer to it.
It all depends on how you barcode scanner works. If it injects data into the keyboard stream, then all you have to do is make sure that the focus is on the textbox. If it sends data to the PC through another means, like the Serial Port, then you'll have to write a communication class to handle that kind of input.
It all depends on the barcode device and how it sends data to the PC...
RageInTheMachine9532
|
|
|
|
|
If it sends data to the PC through another means, like the Serial Port, then you'll have to write a communication class to handle that kind of input.
:::::then how to make that communication class that listen to the serial port ?
i wanna to find the way to to connect to that serialport
i dont know how to make that
|
|
|
|
|
First thing's first...
The make and model of the scanner would be helpful.
Do you have all the docs on the scanner? Do you know the communication requirements of the scanner? Do you know what format the data comes in? Do you have the commands the scanner understands? The formats of those commands?
If not, your wasting your time...
RageInTheMachine9532
|
|
|
|
|
no i have nothing from what u say but i wanna the whole story of using the barecode if have a breif idea about the way to handle the barecode numder from the any kind of serial barecode scanner i dont know any thing about that stuff and i ask any one to help me by him self or by sending me any url to help me in that stuff
and i search and found all the code write in that is for the way to print the barecode but i wanna to input it and how to handle it
thank u and i hope i make my self more clearar
|
|
|
|
|
If you don't have any of that information, you're going to have VERY difficult time doing this.
Basically, all you've told use is that you have a barcode scanner and that you want to write a program. You haven't given us ANY information to work with, yet you want help with writing code.
All I can tell you is to search the web for code samples, search for the manufacturers website and search for the technical docs on the scanner.
You can start with the code in the previous post for Serial Comm in VB.NET and you can also look at the VB6 code here for a barcode scanner example. Don't know if it's going to work for you because you haven't been able to tell us what barcode formats the scanner can read.
http://www.vbexplorer.com/vb/scripts/ShowCode.asp?txtCodeId=47696&lngWId=-1[^]
RageInTheMachine9532
|
|
|
|
|
i need any code example i mean it i need any example
but with the c#
and i need a brief flow chart of how this any serial port
barcode device should be used
all what i need is a brief flow chart with sample of code if possible
|
|
|
|
|
There is a VB6 example here[^]. I can't find any .NET examples anywhere.
RageInTheMachine9532
|
|
|
|
|
thank u so much for ur effort with me
|
|
|
|
|
hi,
in order to help you, you should have a look at this tut -> http://www.devhood.com/tutorials/tutorial_details.aspx?tutorial_id=320
that's all you need
|
|
|
|
|
thank u man so much that is so helpful that what i need
from where r u
?
|
|
|
|
|
I just finished a point of sale system for my universities bookstore. I had a choice of scanners and choose the keyboard wedge scanner. It is the easiest to incorporate into the system as there is no special coding involved. I simply plugged it in, programmed the scanner with the neccessay, and supplied, barcode initializations, and then scanned a code. Sure enough it placed the numeric representation of the code in the textbox that had focus at the time. No special interface coding needed.
I would suggest you look into a keyboard wedge type of scanner.
Joe
|
|
|
|
|
I'd liek to include a couple icons in my EXE file to associate with different file types. I'm having trouble adding the icons to the EXE. I have a program which will extract icons and give me the index number so I can make the entries to the registry, but when i add the ICO file to thwe project and build (both as content and Embedded Resource) only the mail icon is detected when the EXE is examined for icons. Any help would be appreciated.
|
|
|
|
|
Icons cannot be embedded as resources in your assembly and be visible to windows. Keep in mind an assembly - while sharing the same extension as a native library (DLL) (and the PE/COFF header which minor differences) - is much different.
These icons must be in the .rsrc section of your PE/COFF executable. One way to do this is - after you compile your library or application - open it with Visual Studio (as a binary resource) and you'll see the various sections of the .rsrc section, like the VersionInfo block. You can import your icons there and give them resource IDs (if you'd rather refer to them by their resource ID rather than their index). If you've signed your assembly - and any production assemblies should be signed - you'll have to resign them. Typically, it's better to delay signing (see AssemblyDelaySignAttribute ) till after you make these kinds of changes.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Once again, thanks for the help Heath....
|
|
|
|
|
The Installation "Wizard" for a web service, ask you to install the web service in a virtual directory and working in a given port. Is it possible ( if the user has enough right on that machine) to install it "remote" ? ( I mean on the same lan just tell a machine name).
E.g.: I'm on my client machine "Braulio", and from my machine I want to install it on the machine called "WebServer" that I can see in my network ( without using terminal server and that stuff).
Thanks in advance, greetings
Braulio
|
|
|
|
|
Installing Web Serivce is not magic if you don't need some task like server registery , GAC or .... After creating your virtual directory, just copy/paste your bin directory and Web.Config and asmx file into virtual directry. If you can do it from your client machine , thats all you need.
Mazy
"Man is different from animals in that he speculates, a high risk activity." - Edward Hoagland
|
|
|
|
|
Hi Mazdak !
Thanks for the info, I was wondering if the "Installer" that includes Visual Studio can have that option ( I think it seems not... crappy installer... maybe for VStudio 2004 they should enhance it, deployment it's 80 % of the times neccesary).
Bye
Braulio
|
|
|
|
|
Braulio Díez wrote:
Is it possible ( if the user has enough right on that machine) to install it "remote" ?
Why don't you try it and see? The code to do this is a custom action - a compiled DLL hidden from our prying eyes. Only trying it would tell you.
More than likely, though, it goesn't because it doesn't ask for a machine name for which it gets the remote metabase for IIS (via the "iis://" management request). There's nothing stopping you from creating your own if you know how. The installer solution (using Windows Installer) is not meant to be a production-grade solution. For that, see Wise for Windows Installer[^] (have used it from the beta-testing days with them and love it) or the much more expensive and bloated InstallShield Developer[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi, I am trying to create a very simple authentication form, and am receiving an error. Please help!!
This is the code i have used:
public class login : System.Web.UI.Page <br />
{ <br />
protected System.Web.UI.WebControls.TextBox txtUsername; <br />
protected System.Web.UI.WebControls.TextBox txtPassword; <br />
protected System.Web.UI.WebControls.Label lblCorrectLogin; <br />
protected System.Web.UI.WebControls.LinkButton LinkButton1; <br />
protected System.Web.UI.WebControls.Panel pnlLogIn; <br />
protected System.Web.UI.WebControls.Label lblIsAuthenticated; <br />
<br />
<br />
private void Page_Load(object sender, System.EventArgs e) <br />
{ <br />
if (! Page.IsPostBack) <br />
{ <br />
if (Session["isAuthenticated"] == null) <br />
{ <br />
this.lblIsAuthenticated.Text = "null"; <br />
} <br />
else <br />
{ <br />
this.lblIsAuthenticated.Text = Session["isAuthenticated"].ToString(); <br />
} <br />
} <br />
} <br />
<br />
<br />
private void LinkButton1_Click(object sender, System.EventArgs e) <br />
{ <br />
if (this.txtUsername.Text == "admin" && this.txtPassword.Text == "password") <br />
{ <br />
Session["isAuthenticated"] = true; <br />
<br />
Response.Redirect ("hello.aspx"); <br />
} <br />
else <br />
{ <br />
this.lblCorrectLogin.Text = "Authentification Error!"; <br />
} <br />
}
_______________________
I receive this error:
Line 31: if (Session["isAuthenticated"] == null) <br />
Line 32: { <br />
Line 33: this.lblIsAuthenticated.Text = "null"; <br />
Line 34: } <br />
Line 35: else<br />
<br />
Source File: c:\inetpub\wwwroot\authentication\members.aspx.cs Line: 33
_______________________
Thanks for your help!!
|
|
|
|
|
What is your error message? Does your label initialized in InitializeComponent()?
Mazy
"Man is different from animals in that he speculates, a high risk activity." - Edward Hoagland
|
|
|
|
|
mil_an wrote:
Line 31: if (Session["isAuthenticated"] == null)
Line 32: {
Line 33: this.lblIsAuthenticated.Text = "null";
Line 34: }
Line 35: else
Source File: c:\inetpub\wwwroot\authentication\members.aspx.cs Line: 33
You did't say what the error was. You said WHERE it was, but not WHAT...
RageInTheMachine9532
|
|
|
|
|
Hi,
Sorry, this is the error message:
System.NullReferenceException: Object reference not set to an instance of an object.
Thanks,
|
|
|
|