|
I am a little unclear here: you comment that you: "turned a simple program which does not have any visual element into a library before." I believe you imply that you could use that with no problems ... in some context ... but we don't know if you actually used that library on the specific device you mention, a "bar-code" device.
And, we don't know if your WinForms program is controlling the Motorola device through some protocol, or usb or serial connection, or if the device is actually running some flavor of Windows (CE ?).
So, I'm not clear if your current WinForms program contains visual elements, or not, and whether you are asking if those visual elements can be translated onto the device about which I don't know enough to speculate about.
So, a few more details, please.
best, Bill
"I have always wished for my computer to be as easy to use as my
telephone; my wish has come true because I can no longer figure out
how to use my telephone." Bjarne Stroustrop circa 1990
|
|
|
|
|
Bill,
I think the rule for posting here is to keep it simple. And I think I have done it in my original post. As all I want is to ask how to turn a WinForm application into library.
OK. Here is all the glory detail if you don't mind bored.
I have a Motorola bar-code scanning device. I have two programs. One is to read RFID. Another is to use the camera. Both programs are in dot net.
My task is to turn these two programs into one library. My client will use my library to intergrate into their existing application. That application, I assume, is to be loaded into various mobile devices.
I am connecting to the Motorola device via USB.
1) RFID
The original program is a WinForm application. The real logic to read the RFID consists of several library calls. It is nothing more than just:
if (!RFID.Connected())
{
if (RFID.Open(sError))
{
if (RFID.ReadTagID(sTagID, sError))
{
MessageBox.Show("Tag ID: " + sTagID)
}
else
{
MessageBox.Show("Read error: " + sError)
}
else
MessageBox.Show("Open error: " + sError)
}
}
I am able to extract the above code into a class library. The class does not inherit anything.
using Motorola_Lib;
namespace Moto_RFID
{
public class myReadRFID
{
public bool Read(ref String sTagID, ref String sError)
{
}
}
}
Then I create a WinForm program. In there just one button to call the Read() function above.
2) Camera
I have the camera program already. Unlike the RFID logic, which is just to use some function calls from a library, this camera program uses some Windows controls.
Now anyone has any idea on how to turn this camera in WinForm aplication to a library?
And how to test?
|
|
|
|
|
This is what I would do:
1. create a DLL project that holds all the RFID and camera code excluding any GUI stuff.
2. create a EXE project that offers a front-end to demo/test the DLL from #1.
Together, these basically include the code you have now.
Any other app interested in RFID and/or camera should just reference the #1 DLL.
In other words, extract your GUI stuff, keep it as a demo/test bed, and offer the remainder as the solution.
Note: you could of course also have two DLL projects in #1, keeping RFID and camera code strictly separated.
|
|
|
|
|
Luc,
Yes I understand this principle - exclude the GUI stuff and leave that to the testing program. I think I run into a logic problem. If I have to provide / control Camera functionality, I really do have to provide a GUI. At least I have to provide a viewfinder / preview of the image.
I may be wrong. If one can provide functionality to take picture AND without GUI, please let me know.
|
|
|
|
|
if your functionality requires a GUI part, then you need to investigate what technology would suit your end-user application, and provide something that fits that.
Example: for a WinForms environment, you could offer a DLL that holds a Control (actually a UserControl) which does both the GUI and the actual actions as required. And you would probably still want a demo/test exe.
|
|
|
|
|
biop.codeproject wrote: I think the rule for posting here is to keep it simple. And I think I have done it in my original post. As all I want is to ask how to turn a WinForm application into library. There is a difference between keeping a question 'simple,' and providing enough information so that potential responders understand the basic usage scenario well enough to give relevant answers, links to resources, or ask focused questions that further advance you towards your desired goal.
If you were posting on a "dedicated" Motorola Bar-Code tech-support forum, of course you could take it for granted that readers would know you were speaking of using a device "remotely." ... Unless Moto was now offering some new portable wonder that was running Win CE, or Win Whatever, that included a dedicated bar-code readers, and was capable of running a WinForms CE app ?
You have still not answered the significant question of whether you intend for your Class Library to include any Forms: that is a possibility. Personally I would not include a Form in a Control Library, but would make a UserControl (or hack a UserControl so it sub-classed Form), based on my preference that a Class Library include only code.
This subject: building a Class Library with/without a Form in it has been recently discussed here.
My only intent in asking you to clarify the scenario was to be helpful, and, imho, your original scenario description was quite ambiguous.
best, Bill
"I have always wished for my computer to be as easy to use as my telephone; my wish has come true because I can no longer figure out how to use my telephone." Bjarne Stroustrop circa 1990
|
|
|
|
|
In the solution explorer, right-click the project name, select Application, in the Output Type select Class Library. Done.
|
|
|
|
|
This isn't really helpful. All that does is compiles the assembly as a DLL, not an EXE. The EXE can already be used as a library, and the things that need to be done to make it a successful library have nothing to do with what extension you give it.
|
|
|
|
|
Dear All,
I am scratching my head about 4 hours to get this sorted, but without any luck.
what i would like to do is on my windows form, it connects to a remote machine and then display all the programs that installed on a windows server 2003 box on a ListBox, then user can select one of the program, and click the Uninstall button to uninstall the selected program.
I am able to load all the programs installed on the remote machines by this code:
public static ArrayList GetAppLists(string p_machineName)
{
RegistryHive hive = RegistryHive.LocalMachine;
RegistryKey subKey;
string displayName, displayVersion, keyNameCurrentMachine32;
ArrayList al = new ArrayList();
keyNameCurrentMachine32 = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
using (RegistryKey regHive = RegistryKey.OpenRemoteBaseKey(hive, p_machineName))
{
using (RegistryKey regKey = regHive.OpenSubKey(keyNameCurrentMachine32))
{
if (regKey != null)
{
foreach (string k in regKey.GetSubKeyNames())
{
using (subKey = regKey.OpenSubKey(k))
{
displayName = subKey.GetValue("DisplayName") as string;
displayVersion = subKey.GetValue("DisplayVersion") as string;
if (!string.IsNullOrEmpty(displayName))
{
al.Add(displayName + " " + displayVersion);
}
}
}
}
}
}
return al;
}
but when i try to uninstall the particular progarm by this code:
private void UninstallProgram()
{
ConnectionOptions connection = new ConnectionOptions();
connection.Username = txtDomain.Text + "\\" + txtUserName.Text;
connection.Password = txtPassword.Text;
connection.Impersonation = ImpersonationLevel.Impersonate;
connection.Authentication = AuthenticationLevel.Packet;
connection.EnablePrivileges = true;
ManagementScope scope = new ManagementScope(@"\\" + cbServerAddress.Text + "\\root\\cimv2", connection);
ManagementObject app = new ManagementObject(scope,
new ManagementPath("Win32_Product.DisplayName='WinRAR 4.01 (32-bit)', DisplayVersion='4.01.0'"),
null);
MessageBox.Show(app.ToString());
if (app != null)
{
ManagementBaseObject outParams = app.InvokeMethod("Uninstall", null, null);
MessageBox.Show("finished");
}
else
{
MessageBox.Show("cant find app.");
}
}
it always returns "Invalid parameter", and the place throws exception was here:
ManagementObject app = new ManagementObject(scope,
new ManagementPath("Win32_Product.DisplayName='WinRAR 4.01 (32-bit)', DisplayVersion='4.01.0'"),
can someone in here assist me or point me to the right direction will be greatly appreciated.
Many thanks.
Andie
|
|
|
|
|
no one had any clue or i just posted in the wrong section of this forum?
|
|
|
|
|
Hello . I need to use MS Word in my program . i want to create a ms word file from my program and let my user to write his writing or letter or everything and save this document into my database . I do not know how to do this . For example my user wants to write a letter to his boss . so i want to give ability to write it and save that n my database . I do not want to store the address of files . i want to store the whole document in XML datatype Even its template .
so can you help me ?
thanks
|
|
|
|
|
Just start with the basics. Here[^] is a good article on Word Automation to start you off.
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
I am doing an assignment on Backup + Restore database with Stored Procedures.
Backup is ok, but Restore the error: "RESTORE cannot process database 'db_test' because it is in use by this session. It is recommended that the master database be used when performing this operation.".
I tried to fix but the document has not been, hope admin help with this problem. Thanks!
Link source: http://www.mediafire.com/?c1uldq2t7eczw3b
I use C # VS2010 + sql server 2005.
|
|
|
|
|
You are restoring a database that you are also probably using at the same time.
Try making sure you run a restore in the master database.
|
|
|
|
|
I used sql queries Restore is done, but 'Stored Procedures' are not. So I asked to use the 'Stored Procedures' can not do this. And if so please help me modifying my demo about Restore using 'Stored Procedures'
. Thank you very much.
Link: http://www.mediafire.com/?c1uldq2t7eczw3b
|
|
|
|
|
Hi Guys ,
Stuck up in small issue can u any one please help me out of this.
I have exported a excel report as below. But last statement is not executing. After downloading it i want to navigate to other page, But it is throwing exception. I understood that i am clearing the HTTP Response. But can i cal one more HTTP?? or how can i navigate to other page.. Please help on this
string attachment = "attachment; filename=Export.xls";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/ms-excel";
GridView1.RenderControl(htw);
Response.Write(sw.ToString());
Response.End()
Response.Redirect("Downloaded.aspx",false); [Problem][Exception]
|
|
|
|
|
Think about it. When you execute Response.End, that's it. There's nothing else being sent to the client. You cannot redirect a client after you call Response.End.
|
|
|
|
|
Always wrap your code in "pre" tag.
|
|
|
|
|
Hi,
I just need your advise please.. where is the best place to save my error.log? is it in the application folder? or some other common folder?
Thanks,
Jassim
|
|
|
|
|
|
Bert Mitton wrote:
I'll usually save it in the application folder.
It's easier to find, and it can't get confused with the error log from another
program.
and is usually read-only to users running the app, so it's impossible (default user permissions) for the log to be written there.
modified 11-Nov-11 8:51am.
|
|
|
|
|
Wait, why is the answer removed? It's an answer (albeit a wrong one), right? I think the answer shouldn't be removed as it can point out a practice that should be avoided. Dave, Can you please include the original answer in your message?
Oxfords English < Official CCC Players Dictionary
Excuse me for my improper grammar and typos.
It's because English is my primary language, not my first language.
My first languages are C# and Java.
VB, ASP, JS, PHP and SQL are my second language.
Indonesian came as my third language.
My fourth language? I'm still creating it, I'll let you know when it's done!
|
|
|
|
|
Nope, 'cause I can't see it either.
|
|
|
|
|
If you edit the answer you gave, it should give you the message that the user posted. This has worked for me in the past.
|
|
|
|
|