|
|
I've been hacking at this problem for a few month off and on and I can't seem to find a solution.
For parallel computing reasons it is necessary to open up and manage multiple instances of an application (CATIA) get be able to get them through the COM. The problem exists that you can only obtain the first register object in the running objects table with the standard GetObject methods.
My plan was to build a windows service that would be available to my applications through COM and manage the multiple instances of the CATIA application. This way any application started by any user should be able to get the windows service and then the CATIA applications from it. Right?
I first tried this in VB.NET but found out that my VB.NET applications couldn't use the VB.NET dll through the com (or I couldn't get it to work). So I'm now working in C# but I am still having troubles accessing the dll through the COM. I know the dll is being initialized and is running but when i try to test it using VBA in excel using the GetObject method. I can not get the Active X object. I've tried registering the dll in the ROT when initialized but it does not help. Am I missing something or am I wasting my time trying to get this to work.
I've had something similar working before, VB.NET executable with a VB6 wrapper (ActiveX executable). It worked fine alone on the machine but when trying to get the wrapper from a executable started by a cueing system (condor) it would fail to get the Active X object. I was hoping that if the dll was started by the system (windows service) any user could access it. Is this thinking correct?
Thanks,
SC
|
|
|
|
|
Hi
I am quite new in protecting code against hackers. I know that much to obfuscate the the .NET assemblies, but my questions are:
Which is harder for hacker: Reverse engineering the optimized x86 code or obfuscated .NET assembly?
How much extra protection does the standard anti-hacking approaches(checking the correct serial code in different places in code, adding dummy code to serial validation methods, using unmeaningful method names...) add to the obfuscated code.
Thank you for your time.
Uros
|
|
|
|
|
1 - It would be Reverse engineering the optimized x86 code.
2 - I am not a proponent of obfuscation. IMO, obfuscators will just rename classes,methods and variables to some hard to read names.
Here[^] is a good article in which Jon Skeet shares his views on obfuscation. Its worth reading.
|
|
|
|
|
Hi all,
I have this .NET 2.0 application. At several points during the application it asks the user to load a picture from their computer. Basically the code uses an open file dialog box to get the path and then copies that picture from that path into a section in my program's folder. Works great on my XP Pro development machine and on Vista. And it works great if the user is selecting a picture from their desktop.
However, if the user goes to My Computer and then clicks on My Pictures the program bombs and "locks up" (according to the user). I can't recreate the error here but I've managed to capture the sequence. I'm pretty sure both of these errors hit when the system "locks up". This also happens if they go to any other folder's subfolder.
I have no idea how to overcome this or what is even causing it or what to even search on. Help?
Exception Message: External component has thrown an exception.
Stack Trace: at System.Windows.Forms.UnsafeNativeMethods.GetOpenFileName(OPENFILENAME_I ofn)
at System.Windows.Forms.OpenFileDialog.RunFileDialog(OPENFILENAME_I ofn)
at System.Windows.Forms.FileDialog.RunDialog(IntPtr hWndOwner)
at System.Windows.Forms.CommonDialog.ShowDialog(IWin32Window owner)
at System.Windows.Forms.CommonDialog.ShowDialog()
at FirstTimeUser.frmGatherPersInfo.btnLoad_Click(Object sender, EventArgs e)
Exception Message: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Stack Trace: at System.Windows.Forms.UnsafeNativeMethods.IntDestroyWindow(HandleRef hWnd)
at System.Windows.Forms.UnsafeNativeMethods.DestroyWindow(HandleRef hWnd)
at System.Windows.Forms.NativeWindow.DestroyHandle()
at System.Windows.Forms.Control.DestroyHandle()
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
at System.Windows.Forms.Form.ShowDialog()
at MyHealtheFile.modMain.main()
Denise "Hypermommy" Duggan
|
|
|
|
|
Not that it helps you, but one of my dev boxes runs XP Home and I have no problems with this.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
I'm wondering if it has something to do with the specific service pack installed. Would you mind telling me what SP you're running?
Denise "Hypermommy" Duggan
|
|
|
|
|
Currently SP3, but I've upgraded as the SPs have been released and also any HotFixes as I'm notified by Automatic Updates.
My box is not on a network, I don't know if that makes any difference.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
I don't think so as this box is not on a network either. But I'll have to check what the SPs and hotfixes fixed as that may be part of it.
Denise "Hypermommy" Duggan
|
|
|
|
|
I'm posting this in this forum cause I want to do this in .NET.
What I want to do is install a software-based microphone (or other voice input device), to which I can redirect voice coming from an actual hardware-based mic after performing some transforms on the voice input. This way I can make voice-enabled applications (like gTalk) listen on the software mic for voice input.
Can someone please point me in the right direction? Is there any other way to achieve this?
Basically what I'm trying to do is create an application that encrypts/decrypts all voice communication b/w two computers.
|
|
|
|
|
I have a backgroundworker on my form, I start it from the UI thread.
Then it would start a worker thread to do network-consuming task.
private void btnOK_Click(object sender, EventArgs e)
{
DisableForm();
Object obj = GetObjFromUI();
BackgroundWorker saveAsWorker = new BackgroundWorker();
saveAsWorker.DoWork += new DoWorkEventHandler(saveAsWorker_DoWork);
saveAsWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(saveAsWorker_RunWorkerCompleted);
saveAsWorker.RunWorkerAsync(obj);
}
After the task completed, it would return to the UI thread and modify related UI, in the Complete event, it worked very well before.
But now I found some times, the method saveAsWorker_RunWorkerCompleted will return to other thread, which is nor the UI thread, neither the worker thread which run the network-consuming task. So the cross-thread exception will be thrown, when the system try to modify related UI in the method saveAsWorker_RunWorkerCompleted.
I have to write code below, to avoid the cross-thread exception.
void saveAsWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
if (InvokeRequired)
{
Invoke(new MyEventHandler(MyObject_MyEvent), new object[] { sender, e });
}
else{
}
}
But I do not want to call the "if (InvokeRequired)", as before, this method "saveAsWorker_RunWorkerCompleted" was indeed excuted in the UI thread, and I am sure the thread which constructed the Backgroundworker and called RunWorkerAsync() was indeed UI thread. Why does the complete method return to "the 3rd thread" now?
Who knows why? Is any system configuration, for windows and .NET framework?
modified on Monday, August 24, 2009 9:48 PM
|
|
|
|
|
Hi,
You have saveAsWorker declared as a local variable making it eligible for garbage collection as soon as btnOK_OnClick returns. Without knowing the internals of the object it's not possible to predict what would happen after GC if the worker thread was still running.
Declaring saveAsWorker as a class level field will probably solve the problem.
Alan.
|
|
|
|
|
Please use PRE tags to show code, it is part of the forum guidelines. I'm not reading your post as is.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hi,
Assuming the two snippets belong inside a single Form-derived class, your code looks fine to me. Here[^] is a little article I wrote as a summary on the cross-threading issue.
IMO the only way to get into trouble with the code shown would be by creating some new Control(s) in another thread which you shouldn't do ever (e.g. inside the DoWork handler), and then touching them again in the Completed handler.
You may want to add some log("Inside XXX thread ID = "+Thread.GetCurrentThread().ManagedThreadID); lines to the different pieces of your code to better see which thread is doing what.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hi,
I am getting mscorlib:Authentication Failure error while trying to invoke my applicaiton. My code is below
private void InitializeRemoting(out int RemotingPortNumber)
{
// Establish server channel sink provider
BinaryServerFormatterSinkProvider svrSinkProvider = new BinaryServerFormatterSinkProvider();
svrSinkProvider.TypeFilterLevel = TypeFilterLevel.Full;
// Create and register tcp server channel to listen on a port.
m_serverChannel = new TcpServerChannel("ITViewAppOperations", 0,
svrSinkProvider);
ChannelServices.RegisterChannel(m_serverChannel);
string PortNumberString = m_serverChannel.GetChannelUri().Split(':')[2];
RemotingPortNumber = Convert.ToInt32(PortNumberString);
// Register "BridgeFactory.rem" as singleton well know service types.
WellKnownServiceTypeEntry entry1 = new WellKnownServiceTypeEntry(
typeof(IdeWMakerBridge).FullName,
typeof(IdeWMakerBridge).Assembly.FullName, // "Arch.IDE.IdeWmBridge"
"IdeWMakerBridge.rem",WellKnownObjectMode.Singleton);
RemotingConfiguration.RegisterWellKnownServiceType(entry1);
// Get remoting singleton bridge instance.
m_ideWmBridge = Arch.IDE.WMakerBridge.Common.IaaIdeWmBridge)Activator.GetObject(typeof(Arch.IDE.IdeWmBridge.IdeWMakerBridge),
"tcp://localhost:" + RemotingPortNumber + "/IdeWMakerBridge.rem");
SetLifetime(m_ideWmBridge, TimeSpan.FromDays(365*100));
m_ideWmBridge.IdeProxy = m_ideProxy;
m_ideWmBridge.Name = "TestNameABC: " + m_ideProxy.GetType().ToString();
}
I am getting exception at SetLifetime function.
private void SetLifetime(object obj, TimeSpan LeaseTime)
{
((ILease)((MarshalByRefObject)obj).GetLifetimeService()).Renew(LeaseTime);
}
Can I know why this exception is happening and what could be the fix for this.
|
|
|
|
|
Here is what I have:
A calculator program. The user saves his/her settings, then the program calculates a price based on the settings selected. The 28 settings save with My.Settings. I have the user's settings in a property grid, that currently, lists everything in alphabetical order. I would like to have 8 categories, each with a certain number of the settings, mainly for organization. But I don't know how to do that, or where I need to start looking. I would also like to have a description for each item, that shows up at the bottom of the property grid.
Please help me out here. I really don't know where I need to start with this. I have tried:
PropertyGrid1.ControlCollection...
...but that's it. I can't figure out where to go from there.
|
|
|
|
|
You don't manipulate the property grid. Tag each property in your class with a Description attribute. For example, something like this could work:
<Description("Property description goes here")> _
Public ReadOnly Property MyStringProperty As String
Get
Return "Hello, world!"
End Get
End Property
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
Thanks for the reply!
I didn't have a class for this...but I do now:
Imports System.ComponentModel
-DefaultPropertyAttribute("ID")- _
Public Class Prices
Private _tiered As Decimal = CakePriceCalculator.My.Settings.TieredServing
-Category("Base Prices")- _
-DescriptionAttribute("A four-inch Tiered Cake costs this much per serving.")- _
Public Property Tiered() As Decimal
Get
Return _tiered
End Get
Set(ByVal value As Decimal)
_tiered = value
End Set
End Property
End Class
...and on the main form's Load Event:
Dim Price As New Prices
'Setting the PropertyGrid1.SelectObject to Price
Me.PropertyGrid1.SelectedObject = Price
(the "-" signs are supposed to be "less than" or "greater than", but the code isn't showing with them.)
Now that I have that, everything is appearing in categories, having a description, and pulling the values from My.Settings...but I cannot edit or save the values. It seems like they are pulling from the My.Settings for the calculations, but they do not send any changed values back to My.Settings, or save them. When I change the setting like before, then try to calculate the "new" value, it reverts back to the old value.
Any ideas for this?
Thanks!
|
|
|
|
|
I got it:
Imports System.ComponentModel
-DefaultPropertyAttribute("ID")- _
Public Class Prices
Private _tiered As Decimal = CakePriceCalculator.My.Settings.TieredServing
-Category("Base Prices")- _
-DescriptionAttribute("A four-inch Tiered Cake costs this much per serving.")- _
Public Property Tiered() As Decimal
Get
Return _tiered
End Get
Set(ByVal value As Decimal)
_tiered = value
CakePriceCalculator.My.Settings.TieredServing = value
End Set
End Property
End Class
(Where the "-" are, replace with opening less than, and closing greater than signs)
From my class, after my Set statement I had to update everything from there.
|
|
|
|
|
Hello, This is Vikash Gohil.
I have a problem in taking Back-up of Database.
I am using SQL 2000 MSDE version.
Actually the database I am trying to back-up is of around 350 MB size (.mdf file)
The Code works properly on normal size databases.
I am getting error of Time-Out while running Back-Up query on this Large Database.
Can anyone please suggest me on how to take Back-up of Large databases through Code.
Any help would be appreciated.
Thanks in Advance.
|
|
|
|
|
Hello.
In my windows application I have a subclassed Form (MyWin) that is opened as a top level window with myWin.Show(). MyWin contains a RichTextBox where the user is supposed to type in text. When myWin is closed by the user the text is saved to a file. I implement this by overriding OnClosing in MyWin and save the text from the RichTextBox there. This works fine when the user explicitly close myWin. But since myWin isn’t the main window in the application myWin can be closed implicitly when the application exits. When this happends the overridden OnClosing function will not be called, so the text will not be saved in this case.
I have tried to add a delegate to Application.ApplicationExit and Application.ThreadExit from MyWin to save the text from there. But that doesn’t work because when these delegates are called the RichTextBox has already been destroyed and its Text field is empty. I want MyWin to be autonomous so I don’t want to be dependent on some Save function that must be called when the main window closes.
So, what I need is someway to detect when the application is about to close, something like Application.BeforeExit but I cannot find anyway to do this. I thought that if I could retrieve the main window in the application,from MyWin, I could add a delegate to its Closing event, but I cannot find any way to do this. I have searched and found Application.Current.MainWindow in PresentationFramework, which I don’t know what it is, but when I try to use this the Application.Current is always null.
So, if anyone knows how to detect when the application is about to be closed before anything is actually closed I would appreciate some help.
Regards
Peter
|
|
|
|
|
Hi,
[EDIT}Use the FormClosing event, not the Closing event![/EDIT]
if the MainForm opened some OtherForm which may hold dirty data, then MainForm.OnFormClosing should perform an OtherForm.Close(), and of course OtherForm.OnFormClosing should deal with the dirty data.
BTW: If keeping track of which forms got opened is too difficult, you could rely on Application.OpenForms and try and close those Forms one by one.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
modified on Sunday, August 23, 2009 4:24 AM
|
|
|
|
|
See you can add new Class and a Method in that Class.
Then you can add a Handler for Application.Exit event which references the above Class method.
See below Code.
Class File Code:
Public Class ShutDown
Public Shared Sub OnShutdown(ByVal sender As Object, ByVal e As System.EventArgs)
Try
Catch ex As Exception
Finally
End Try
End Sub
End Class
Form Code That Loads When Application Starts:
Sub New()
InitialiseComponents
AddHandler Application.ApplicationExit, AddressOf ShutDown.OnShutdown
End Sub
The Above Code would Catch the Application.Exit event and run the OnShutDown Procedure.
You can write the Code that you want to Execute in the OnShutDown Method.
Hope This Helps.
|
|
|
|
|
I think you may be looking for a specific Windows message... You can override PreProcessMessage in your form and basically "hook" all manner of unusual things. I wish I knew which one you were looking for exactly or if it even exists, but whenever I've had to handle unusual user actions that didn't really exist as ordinary events, this has worked for me. It's just been a matter of finding the correct combination of msg.Msg , msg.HWnd , and msg.LParam that you are looking for in the overriden PreProcessMessage routine.
|
|
|
|
|
Override OnClosed in MyWin instead of OnClosing. The RichTextBox.Text property will still be valid. MyWin.OnClosed does get called when the main form is closed, whereas MyWin.OnClosing does not.
Eagles my fly, but weasels don't get sucked into jet engines.
|
|
|
|