Deploying native code.
The scenario is we're about to release an exe to our clients. It's a
winforms application that uses reflection, remoting, generics, and
serialization. We want to protect the intellectual proprety rights of our
code. One solution is to obfuscate the exe. I've come across some 3rd party
solutions that claim they can compile the exe to native code (xenocode,
remotesoft, etc). I'm wondering if there is some tool in the .NET framework
that can compile winforms applications directly to native code, thereby
bypassing MSIL + JIT compilation? The native executable can then be
deployed.
I've read about the ngen utility, but it doesn't seem applicable in this
case. From my understanding, ngen will precompile the exe and add it to the
native image cache on the respective machine. What I'm looking for here is a
way to bypass MSIL + JIT compilation.
Thank you! Tag: Simple, Simple Question Tag: 116910
setting ShowInTaskBar to 'false at run-time : strange errors, crashes
.NET 2.0, Visual Studio 2005
Hi,
I have several open windows, all instances of the same form template created
dynamically in response to a user action at run-time.
A user option for the application is to show all open windows in the task
bar, or only the current
active window.
I thought I could write handlers for the Form_Activated and Form_Deactivate
events of all these instances of a form_template, but I'm running into
strange errors when I set 'ShowInTaskBar to false in the 'Deactivate event
like : "can't create window handle," or "callback on a delegate that has
been garbage collected."
At first I thought these error might be related to deisgn mode, but they
persist when I run the .exe file, giving an error dialogue that does not
provide the usual debugging information.
Googling on "microsoft: showintaskbar" led to several reports that suggest
errors with setting showintaskbar to false at runtime. Francisco Balena at :
http://www.devx.com/vb2themax/Tip/18334
Says the property is read-only at run-time, but in another part of my
application I have a menu that toggles showing all, or only the active form,
in the taskbar : this code loops through a collection of open forms I
maintain and sets showintaskbar properly and with no errors !
I am aware that winforms does some strange stuff when you set ShowInTaskBar
to 'false :
"After doing some research, I found that
setting Form.ShowInTaskbar=false will close window's WS_EX_APPWINDOW flag,
and set window's owner form to WindowsFormsParkingWindow, which is an
invisible toplevel window(internal )" comments Jeffrey Tan from Microsoft at
:
http://www.dotnet247.com/247reference/msgs/57/285697.aspx
Okay my questions :
1. is switching a window's ShowInTaskBar status something that will require
use of Interop and API's in .NET 2.0 ?
2. has there been a change in versions of .NET > 2.0 that make this possible
without use of API's.
In this particular design scenario there is no one window which is always
necessarily visible, no "master form." Each winform created has its Parent
property set to Null. And, yes, Form_Closing events are modified to detect
need to terminate the app because, in this case I am using Application.Run()
after an initial template form is shown.
thanks, Bill Tag: Simple, Simple Question Tag: 116909
NotifyIcon on a Dialog Box
[Using VB.NET 2005]
We've got an old application that has been modified quite a bit.
Originally, it was just a single form application that hid in the Task Bar
Tray using a Notify Icon.
Later, we had to add a Custom Dialog Box to the project.
Now, it has been determined that the project would be best served by the
Dialog Box only, and eliminate the main form.
So, the project is now a Console-like Application that starts with a Main
Module. The Notify Icon had to be included with the Dialog Box, otherwise we
weren't able to make it work.
The Notify Icon has a Context Menu Strip and events for Click and Double
Click.
When the Main Module starts, it creates a new instance of the Dialog Box,
but does not show it.
When the Dialog Box is created, it creates and shows the Notify Icon.
If you are still reading this, here is the problem:
Unless the Dialog Box is being displayed (dialog1.ShowModal), all the Notify
Icon will do is show its Balloon Message. The Click, Double Click, and
Context Menu Strip does not react at all.
Any idea why? How would I get this to work? Tag: Simple, Simple Question Tag: 116908
Need 2nd opinion about program style
This might be a silly question but....
I have not made much use of modules in recent years. I've been called on to
translate an old VB6 program to Dot Net 2.0. Aside from the sheer complexity
and lack of docs, there is one thing that caught my attention: The original
programmer made a great deal of use of modules in his DLLs. One element of
his style was to create class declarations in the module (Public x as Class1)
and then set x to reference the class in the class itself (x = Me).
Now I've whipped up a little test program and I know this still works but I
was just wondering how this measures up as acceptable (or should I say
'modern') programming style?
(It seems an innocent enough technique but given that the legacy program as
a whole is major spaghetti, I thought I'd ask for a second opinion.) Tag: Simple, Simple Question Tag: 116907
Setup of .net 3.5 fw takes FOREVER - idea why?
I created a program (.net 3.5). I created a setup program and tried to
install it on another computer. The .net 3.5 framework took like 25 minutes
to install. Any idea why? Another customer had a similar issue. They
state that the fw was like 197mb.
Also, they had an error like this:
Component .NET Framework 3.5 has failed to install with the following error
message:
"The wrong diskette is in the drive. Insert %2 (Volume Serial Number:
%3) into drive %1. "
The following components failed to install:
- .NET Framework 3.5
See the setup log file located at
'C:\Users\QUENCH~1\AppData\Local\Temp\VSDA15D.tmp\install.log' for more
information.
Any ideas on these 2 issues? Tag: Simple, Simple Question Tag: 116904
=?Utf-8?Q?How_to_redirect_multiple_website?=
Hi Guys,
I have multiple domain names www.alnajdawi.com, alnajdawi.com,
www.alnajdawi.net, alnajdawi.net as a host headers in IIS 6.0
I want to know how can I redirect all these URLâ??s to one URL
www.alnajdawi.com, so if a user entered one of these URLâ??s he has to be
redirected to www.alnajdawi.com
Thanks,
MSN Tag: Simple, Simple Question Tag: 116903
GC.Collect() not cleaning memory, how to find out what references to lots of memory still exist?
GC.Collect() not cleaning memory, how to find out what references to lots of
memory still exist?
When all my processign is done i set everything to null and then:
GC.Collect();
and then
GC.WaitForPendingFinalizers();
but it still shows that my process takes 400 MB of memory. Is there any easy
way to see what references that I forgot to set to null so that the memory
cleas up on GC.Collect() ? Tag: Simple, Simple Question Tag: 116899
".resx" files not kept up-to-date by Visual Studio
Hi there,
Can anyone explain why the assembly qualified names seen in the ".resx" file
for each form in an application aren't kept up-to-date by Visual Studio. For
instance, if a dialog uses a user control from some other library in the
same solution, the user control's assembly qualified name will appear in the
dialog's ".resx" file. Each time the control's library is compiled however,
the library's version is incremented but the ".resx" file continues to show
the original version number. How then does Visual Studio load it when the
dialog is displayed in the Visual Studio designer? If all projects are
signed then the control's library identity won't match what's in the '.resx"
file but Visual Studio seems to ignore this. Can anyone shed any light on
the situation? Thanks in advance. Tag: Simple, Simple Question Tag: 116898
Bug in ComboBox with AutoCompletion?
Hi,
I have a strange problem. The Combobox component always raises an
OnTextChanged event when it is validated and auto completion is
activate.
Take a look at .NET framework source code, ComboBox.cs, method
"OnValidating". This method calls "NotifyAutoComplete()", which itself
calls "OnTextChanged" when the selected index was not changed - it does
not check if the text was really changed!
This for example causes that the OnTextChanged event is always raised
when the ComboBox looses focus. There are several other ways where the
event is raised where it should not.
Any ideas?
Carsten Tag: Simple, Simple Question Tag: 116897
General question about VB6-Dot Net conversion
I've been tasked with converting a VB6 exe (plus associated dlls.) The
conversion is not supposed to be exact so the conversion wizard is probably
not an option. I'm more concerned about basic conceptual matters at this
point (especially since the legacy code is extremely complex and downright
strange in places.).
Can anyone point me to a favorite reference or discussion on this subject?
(I can probably wing it but I'd like to avoid common pitfalls.) Tag: Simple, Simple Question Tag: 116896
image from url in datagridview
Does anybody know if it's possible to have a winform datagridview show an
image in a column that comes from a url?
thanx,
Tom Tag: Simple, Simple Question Tag: 116895
Installation problem
Hi people
I am having problems with DotNet. I accidently deleted .net 2 sp1 from my
machine, and I need to re-install. I have searched the MS site for
information, and have followed the advice I found. My problem is a round
robin thing whereby I can not install .Net 2 because my machine insists that
it is incompatible. I have done all I can from the information I have from MS
KBs. I have .net 1.1 installed, .net 2 refuses to re-install as does .net 2
sp1.
I need a foolproof (!) way of uninstalling and re-installing this software.
(Even MS Update fials to install). Help?! Tag: Simple, Simple Question Tag: 116894
DataGridView: draw only a border for selected row
Hi all,
is there a way to highlight a selected row (in a grid that allow only a row
selected, or even just a cell at one time), drawing only a thick border
around the row (but not between the cells of the same row) instead of the
highlight blue background?
I couldn't find any way to do it correctly Tag: Simple, Simple Question Tag: 116890
Windows Virtual memory --minimum?
How do I fix this problem ? It keeps poping up once in a while? Read out
says that the virtual memory is low Tag: Simple, Simple Question Tag: 116888
Installation error (GAC)
I am using the trial version of MailBee.NET IMAP.
I created a program and made a setup package. I installed it on my other
vista machine and I get this error:
Unable to install or run the application. The application requires that
assembly MailBee.NET Version 3.0.2.79 be installed in the Global Assembly
Cache (GAC) first. Please contact your sys admin.
Any ideas how to fix this? Tag: Simple, Simple Question Tag: 116886
80070008, WindowsUpdate_dt000
80070008, WindowsUpdate_dt000. Thats the error im getting when i try to
install service pack 1. I have enough memory and all the requierments. I
tried troubleshooting the error with their service page. I am getting an
error when i try to install my webcam "not enough storage to install this
device" and i think the problam has to do with the same prob im getting from
trying to install sp1. Any help would help alot, im very stressed over this
issue. Tag: Simple, Simple Question Tag: 116879
Tab control and navigation buttons
Hello -
I have a tabbed control on a form that is populated from a database. I have
a request to change the application to include a navigation button for
customers that have multiple records.
I have created navigation buttons for use in forms, however, I have never
developed them specifically for a tab control. Is it possible to do this?
Any help will be greatly appreciated!
--
Sheldon Tag: Simple, Simple Question Tag: 116872
Button stuck disabled when running under VS Debugger
Hello all,
I'm experiencing a samewhat strange behaviour when running my Windows
Forms app from withing Visual Studio 2008. The application is
multithreaded and the workerthread fires an event that should enable a
button in the GUI. I'm using BeginInvoke to call the method that enables
the button on the GUI thread. The code is very straight forward:
On the worker thread:
[...]
ffmpegProcess.WaitForExit();
if (GeneratorFinished != null)
{
GeneratorFinished(this, null); //event that triggers the button enabler
}
In the GUI Class:
void generator_GeneratorFinished(object sender, EventArgs e)
{
if (this.InvokeRequired)
{
MethodInvoker invoker = new MethodInvoker(EnableStartButton);
invoker.BeginInvoke(null, null);
}
else
{
EnableStartButton();
}
}
private void EnableStartButton()
{
btnStart.Enabled = true;
}
This works as expected when running the program outside of VS. However if
I start the Program within VS (by hitting F5) the Button does change its
appearance from disabled to enabled but does still not accept mouse
input. The button works when I press the accelerator key (Alt+S). I can
also tab to the button (it recieves focus) and press enter. However
tabbing to it and pressing space doesn't work. Once the button got
activated via tab+enter or the accelerator key it 'unsticks' and accepts
mouse input again.
It's not a big deal but a little annyoing and I'm curious if there's
anything I can do to prevent it from happening?
Thanks
Ben Tag: Simple, Simple Question Tag: 116869
ClickOnce: Certificate cannot be validated
Hi,
We are signing our ClickOnce manifests with a code signing certificate
purchased from Thawte. When we install the software a security warning is
shown, and when we click on the publisher it says the certificate can not be
validated. This is because the "Thawte Code Signing CA" is not present on
the client machines.
Having done a web search, I found a previous post in this group describing
exactly the same issue - viewable at:
http://groups.google.com/group/microsoft.public.dotnet.framework.windowsforms/browse_thread/thread/8c46df2acf25d54/4c1c4221f69fa09e
From one reply from Linda Liu [MSFT]:
>I searched in our inner database and found a similar issue in it. The
>following is the comments:
>
>Firstly, this is a known issue that is being addressed in the next version
>of Visual Studio - The Orcas.
>Click Once apps do not distribute certificate/cert chains on the fly. So
>for path validation to be recognized at install time - the installing
>machine must have the intermediate certificate in this specific case.
My investigations have not yet turned up any CAs that offer code signing
certificates that directly chain from certificates we will find on our very
vanilla customer machines - they all seem to use intermediate certs. (I'd
love to be proved wrong on this...)
My real question relates to the comment that this is being addressed in the
Orcas release of Visual Studio. Is this true? If so, is there support in
framework 3.5 that can be accessed via cClickOnce APIs?
Thanks,
Tony Tag: Simple, Simple Question Tag: 116861
Open Outlook form through VB.NET
Hi guys,
Wonder whether I could get help !! I want to open Outlook form through
my VB.NET ? What is the best way of doing it ?
At the moment, I could do by sending keys to Outlook and opening it.
However, just wondering there is better ways of doing it...?? Tag: Simple, Simple Question Tag: 116859
First chance exceptions
Hi
When running my app in vs 2008 IDE I get the below messages in the Immediate
Window repeatedly.
A first chance exception of type 'System.NullReferenceException' occurred in
MyApp.exe
A first chance exception of type
'System.Runtime.InteropServices.InvalidComObjectException' occurred in
MyApp.exe
A first chance exception of type 'System.IO.FileNotFoundException' occurred
in System.Drawing.dll
A first chance exception of type 'System.ArgumentNullException' occurred in
mscorlib.dll
They don't crash the app but it seems the app slows downs when one of these
errors occurs. What is the problem and how can I fix tit?
Thanks
Regards Tag: Simple, Simple Question Tag: 116856
Form-to-Form Control
I am using C # .NET Framework 3.5.
I have a calling form that invokes dialog box (called form). I want a
button in the called form to change the value of a property in a control in
the calling form.
Clearly I could set a return code in the called form and have it acted on
when control is returned to the calling form.
Is there a technique that I can use that would allow me to have a routine in
the called form change the content of a control in the calling form without
returning control to the calling form?
... Thom
___________________________________________________
Thom Little - www.tlanet.net - Thom Little Associates, Ltd. Tag: Simple, Simple Question Tag: 116853
Accessing the status bar
In my winforms app, I have a MainForm which has a panel on it called
ContentPanel. ContentPanel holds a User Control which consists of a grid of
records depending on whether it is customers, invoices etc. From within the
user control which is sitting in the panel on the MainForm how can I access
the status bar?
Bill Tag: Simple, Simple Question Tag: 116851
Acessining the status bar
In my winforms app, I have a MainForm which has a panel on it called
ContentPanel. ContentPanel holds a User Control which consists of a grid of
records depending on whether it is customers, invoices etc. From within the
user control which is sitting in the panel on the MainForm how can I access
the status bar?
Bill Tag: Simple, Simple Question Tag: 116850
Can I create a Windows Explorer Icon type object in .NET
I am trying to create a Windows Explorer icon type object in .NET that
will display an icon image and have a label that works like the label on
an icon in Windows Explorer; maximum two-line display that expands to
full-size when selected and is editable. I would also like to be able
to have it contained on a Form and be able to reposition it by changing
a "Location" property. I have experimented with PictureBox and Panel
box objects without any success. Is there such an object available in
.NET (or natively)? The editable label is especially interesting.
For now I have implemented a static display use the various Graphic
class methods; DrawImage and DrawString but they really do not replace
the advantage of having a true icon type object that I could click and
manipulate.
Robert Tag: Simple, Simple Question Tag: 116846
TableNewRow event handling issue
Greetings,
Using VS 2005 SP1; I created a simple form by dragging and dropping a data
table. I changed it to a details view, so I have a mixture of text boxes,
combo boxes and a check box (no dgv). I want to programatically populate the
controls when the user clicks on the Add New button, so I added the following
event handler:
void MyDataTable_TableNewRow(object sender, DataTableNewRowEventArgs e)
{
int nIndex = int.Parse(this.bindingNavigatorPositionItem.Text);
e.Row.BeginEdit();
e.Row["Col0"] =
this.myDataSet.MyDataTable.Rows[nIndex].ItemArray[0].ToString();
e.Row["Col1"] =
this.myDataSet.MyDataTable.Rows[nIndex].ItemArray[1].ToString();
e.Row["Col2"] =
this.myDataSet.MyDataTable.Rows[nIndex].ItemArray[2].ToString();
...etc...
e.Row.EndEdit();
}
This works surprisingly well; the user can select any row and use it as a
template for the new row. I tried to take this a step further; instead of
setting the columns individually, I tried to use the CopyTo function as
follows:
void MyDataTable_TableNewRow(object sender, DataTableNewRowEventArgs e)
{
int nIndex = int.Parse(this.bindingNavigatorPositionItem.Text);
e.Row.BeginEdit();
this.myDataSet.MyDataTable.Rows[nIndex].ItemArray.CopyTo(e.Row.ItemArray,
0);
e.Row.EndEdit();
}
The code seems to execute, but all my controls are blank, like the CopyTo
did nothing; what am I missing here? Shouldn't this work?
--
Regards, Bob Tag: Simple, Simple Question Tag: 116843
Creating GroupBox with Radio Buttons from enum using reflection
Hi,
I am using reflection to read names from enum and creating radio buttons
inside a groupbox. Everything is working fine. However, I am not able to
adjust the size of the group box to fit the content. Is there a simple
solution to this problem? Parent of group box is FlowLayoutPanel which fills
the parent form.
string[] names = Enum.GetNames(pi.PropertyType); //pi is a PropertyInfo
object which represents a property of type enum.
GroupBox gbx = new GroupBox();
//gbx.AutoSize = true;
gbx.Name = "gbx" + pi.Name;
gbx.Text = pi.Name;
gbx.Padding = new Padding(2, 5, 2, 2);
panel.Controls.Add(gbx);
TableLayoutPanel tlp = new TableLayoutPanel();
tlp.ColumnCount = (int)Math.Floor(Math.Sqrt(names.Length));
tlp.Dock = DockStyle.Fill;
tlp.Padding = new Padding(1);
//int maxRBLength = 0;
foreach (string name in names)
{
RadioButton rb = new RadioButton();
rb.Name = "rb" + name;
rb.Text = name;
rb.AutoSize = true;
rb.Margin = new Padding(0, 0, 0, 0);
//if (rb.Width > maxRBLength) maxRBLength = rb.Width;
tlp.Controls.Add(rb);
}
gbx.Controls.Add(tlp);
Thanks
SG Tag: Simple, Simple Question Tag: 116837
Pagefile on iSCSI Disks
I'm having problems creating large pagefiles on os disk conencted via MS
iSCSI Initiator.
I'm guessing this is because the iSCSI disk is not available at the time
Windows tries to create the pagefile, does anyone know a way arond this ?
Thanks Tag: Simple, Simple Question Tag: 116833
Saving file dialog
Hi
I am using an open file dialog which allows me to select a file to open.
This is all great. But it does not allow me to give a filename and select
folder to save the file to if the file does not already exist. How can I
implement save file functionality?
Thanks
Regards Tag: Simple, Simple Question Tag: 116823
Slow app response
Hi
I have replaced an ms access app with its vb.net version at a client site.
Now the clients keeps complaining about how slow the app response is. The
complains they have are for example when app is minimised and then trying to
maximise it after a while takes a while for app to get maximised. Also form
painting of controls is slow and app is generally slow in terms of response
to user clicks. I am using Infragistics controls and my feeling is that
makes the app bit sluggish compared to the original controls shipped with vs
2008 but I need the Infragistics controls for their features. I have also
ngen'd the app but surprisingly only the main app executable gets ngen'd and
not any of the dependency dlls such as Infragistics dlls.
Are there any tips to make app response better for user?
Thanks
Regards Tag: Simple, Simple Question Tag: 116822
Bootmgr. missing
Hey all you fine technological geniuses! I have seen some of you having some
problem as I have encountered the last week. When starting up the computer
says: 'Bootmgr. missing - press ctrl.-alt-delete to restart'. I think I might
have tried everything you have suggested and more to it, but the problem
still remains - do anyone have a new solution to my problem - it starts to
aggrevate me! By the why - I'm running Vista home premium.
--
Midtgaard Tag: Simple, Simple Question Tag: 116820
Upgrade to Vista Ultimate broke VS 2008
I had Vista Home Premium with VS 2008 - worked just great.
Upgraded to Vista Ultimate - now with a Windows App the following happens:
1. Try to open Form1 in designers mode (new app or existing app), error =
"The service Microsoft.VisualStudio.Shell.Interop.ISelectionContainer
already exists in the service container".
2. Compile app (new or existing), build error = ".NET Framework 2.0 update
not found. The win32manifest will not be embedded" Tag: Simple, Simple Question Tag: 116815
ClickOnce Updates from a Different Publish Server
Hi,
I'm currently using ClickOnce to deploy an application written in Visual C#
2005. The client has it installed already.
I'm wondering if there is a way to change the client to point to a different
publish server (http://66.x.x.x/app) to download updates without uninstalling
and installing the client.
Thanks. Tag: Simple, Simple Question Tag: 116808
Calling a form in second project
Hi
Can I run a from in one project from a second project, both projects being
in the same solution?
Thanks
Regards Tag: Simple, Simple Question Tag: 116801
Getting TextBox default height
Is there a way to get the height of a textbox without creating one?
Basically I can use this:
TextBox tbox = new TextBox();
height = tbox.Height;
but I would rather not create a temporary object if there is some
static method to get the height. I want to draw some rectangles that
have the same height as the default TextBox. Tag: Simple, Simple Question Tag: 116797
Converting a DataColumn's Datatype on the fly
Hi everyone,
I have one dataset that gets built dynamically from XML, I parse a
large soap message and extract the schema from XML( I am working
in .NET 1.0, sorry for the pain). anyway, by default the dataset
resutling from this
process has a data type of string for all columns. My question is :
Is there a way to convert the datatype of columns from String to
Double, or to any other format, on the fly?
I know for a fact that all values in that datacolumn are all doubles.
One thing I am doing is creating a new column with a datatype of
double, and then looping through all existing row in the string column
and then converting them, but this is a nightmare as the size of the
table grows.
Thank you. Tag: Simple, Simple Question Tag: 116796
Driving me nuts! How to do two-levels inheritance under UserControl?
I have a few types of panels (each with different controls), which I
will create dynamically and place on a form.
I can make them UserControls if I need to.
However I would like to have a base class for these, so that I have a
class hierarchy like:
System.Windows.Forms.Panel
|
|
MyBasePanelClassWithOverridableMethods
| |
| |
MyPanelType1 MyPanelType2
I tried to create a UserControl and inserted a base class within
Notepad, changing:
----------------------
Partial Class UserControl1
Inherits System.Windows.Forms.UserControl
---------------------
To:
----------------------
Partial Class MyBaseUserControl
Inherits System.Windows.Forms.UserControl
End Class
Partial Class UserControl1
Inherits Class MyBaseUserControl
------------------------
...and DevStudio2008 gives me an error "Value does not fall within
expected range", which is useless.
Is there something more I need to do to insert my base class?
Is there another way to achieve what I need to achieve? I need
MyPanelType1 and MyPanelType2 to be editable as far as contained
controls, etc...
Thanks! Tag: Simple, Simple Question Tag: 116791
CollectionEditor Avoiding duplicates
Hi
I am using a collectioneditor to populate a List. I don't want
duplicates entries in the list. But collectioneditor just puts what
ever we insert. It wont check for duplicate entries. How to do it.
Thanks in advance
sriraj Tag: Simple, Simple Question Tag: 116787
Keys.Control and Keys.ControlKey
Does anyone know what the difference between Keys.Control and
Keys.ControlKey is? Same goes for Keys.Shift and Keys.ShiftKey. What's
the correct usage for these values? Tag: Simple, Simple Question Tag: 116776
tracking logged in User
I have a winform app that validates a user against a table in my database.
I want to track the user throughout the program for maintaining permissions
to access parts of the program etc. In a web app, I would just throw the
current user into a session varaible and access it from any webform. What's
the proper way to do this in a winform app?
Bill Tag: Simple, Simple Question Tag: 116775
ToolStripComboBox.ComboBox
What is the deal with this property? As long as the ToolStripComboBox is
visible on the ToolStrip, it seems to work fine. However, if the ToolStrip
gets shrunk to a size that the ToolStripComboBox is only accessable through
the extension button, the ComboBox property starts behaving in a manner that
I do not expect. In particular the SelectedValue property does not work. Is
this by design? I can not find any articles explaining why the ComboBox
would not always just work. Tag: Simple, Simple Question Tag: 116774
Using OCX in a Windows Service
Hello there,
I am creating a windows service to monitor wireless terminals and then
transmit the barcodes to the clients. The service needs to use a OCX (I hate
to use OCX in a service but, without OCX, you wont be connected to the base
station). I have added a form and used the ocx on the form only to connect to
the base station.
However, I do get a message in the event log. The service won't start.
Service cannot be started. System.Threading.ThreadStateException: ActiveX
control '244758c6-a002-11d2-b82b-938daecfce37' cannot be instantiated because
the current thread is not in a single-threaded apartment.
at System.Windows.Forms.AxHost..ctor(String clsid, Int32 flags)
at System.Windows.Forms.AxHost..ctor(String clsid)
at AxPLSERVERLib.AxPLServer..ctor()
at WHE.PandD.WHEPLSContainer.InitializeComponent()
at WHE.PandD.WHEPLSContainer..ctor()
at WHE.PandD.WHEDespatchServiceFacade.StartWorking()
at WHE.PandD.WHEDespatchService.OnStart(String[] args)
at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object
state)
For more information, see Help and Support Center at
http://go.microsoft.com/fwlink/events.asp.
I have set [STAThread] attribute and also tried
System.Threading.Thread.CurrentThread.TrySetApartmentState(System.Threading.ApartmentState.STA);
Could you please let me know what I am doing silly here?
Ta
Mahesh Tag: Simple, Simple Question Tag: 116773
.Net form as child of Visio window
Hi,
I am writing a Visio add-on using VB.Net.
I have a form that I want to display as a child of a Visio drawing
window and I want to display it modally. So I'm using this code:
Dim myForm as New Form
Dim visioWindow as Visio.Window = visioApp.Window
SetParent(myForm.Hand.ToInt32(), visioWindow.WindowHandl32)
myForm.ShowDialog()
This correctly displays the form but unfortunately freezes not only
the form but the whole Visio UI. Nothing is clickable.
I want to know if someone has an alternate way to show a VB.net form
modally as a child of visio (or for that matter any office app because
all of them are written in COM) that does not have this problem.
Please help.
Thanks in advance.
~Gurinder Tag: Simple, Simple Question Tag: 116772
Datagridview + ContextMenuStrip: How to get the column?
Hi,
I have a datagridview on my form and I want the user to be able to remove
columns.
I have added a simple contextmenustrip to the datagridview but now when the
user rightclicks on the column the menu is shown before the column click is
handled.
So how can I get the column index for that right-clicked-column?
rg,
Eric Tag: Simple, Simple Question Tag: 116770
URGENT: Gmail API for VB.NET
I am making a WinForms Application to interface with GMail. The user should
be able to:
1. Login to GMail
2. Go thru the inbox 1 message at a time
3. Read the message and some message attributes (From/To, Date, etc...)
Any good GMail APIs you know of to help me out?
Thanks! Tag: Simple, Simple Question Tag: 116766
custom TextBox
Hello all, I wanted some advice on the easiest way to go about the
following:
I have some TextBoxes that are enabled/disabled at various times in
the program. When they are disabled, the default is a gray background
with dark gray text. Is it possible to customize the text color when
the TextBox is disabled. For example, make it red? Tag: Simple, Simple Question Tag: 116759
winproc
hi,
i worte an application with C# and i am monitoring the comming Messages by
overloading the WinProc.
but when the pc is Locked out no new Message is monitor,
?????? Tag: Simple, Simple Question Tag: 116757
In ASP.Net a datagridview has an event called RowDataBind. What's the
equivalent in a Windows Form Gridview?