|
Hello,
(This applies to C# as well)
I am building a tool using .Net remoting. If I obtain a proxy by Activator.GetObject and then want to switch that proxy by calling Activator.GetObject again with a different parameter - and I do this on a separate thread than the thread(s) that is/are using that proxy, could I run in to trouble? Right now I am using a SyncLock, but there could be several threads using this object, so each one has to wait its turn - even though the server code can handle several asynchronous calls just fine. Could I remove the SyncLocks with no worries?
If you need a little more explanation:
There will be several servers in different locations running the server code via a Windows service. These services may go down, start up, stop working, etc., so my client code may need to switch where it gets the proxy from. I have a separate thread that monitors these servers and tries to maintain the best connection. I want to know if there is a problem if a thread starts using the proxy, and then the connection thread switches the proxy. I assumed there was a problem so I used SyncLocks, which is also causing problems, so if possible, I want to remove the SyncLocks.
Thanks,
Kevin
|
|
|
|
|
Hi all.
I want to make my pen drive password protected so that each time when I insert my pendrive it will ask for a password to access pen drive.
Suggest me how to do this.
Thanks.
Gagan
|
|
|
|
|
You cannot do it in VB.NET or managed code. This requires writing an extension to NTFS.
You're not actually password protecting the contents of the drive. The "drive" will be an encrypted file that is NOT protected on the normal drive. The contents of the file will be what your extension exposes as part of the file system. All I/O has to go through your extension to be encrypted/decrypted in and out of your file. Basically, your making an encrypted .ZIP file and exposing it through an NTFS extension.
|
|
|
|
|
I've been experimenting with TrueCrypt[^]and looks good to me, so far. Steve Jowett
-------------------------
Real programmers don't comment their code. If it was hard to write, it should be hard to read.
|
|
|
|
|
Hi all.
I am trying to format my pen drive by creating a process of command prompt and using "format" command (without quotes) in vb.net.
The code I am using is below :
Try
Dim pr As New Process
With pr.StartInfo
.FileName = "cmd.exe"
.RedirectStandardInput = True
.RedirectStandardOutput = True
.UseShellExecute = False
.WindowStyle = ProcessWindowStyle.Normal
End With
pr.Start()
pr.StandardInput.WriteLine("format G:" & Convert.ToCha(13)) 'enter to take the pen drive.
pr.StandardInput.WriteLine("{ENTER}") 'next enter to start the formatting process.
catch ex as exception
msgbox(ex.message)
end try
Here my pen drive's drive is G: drive which I want to format.
This code starts the formatting process but it is not formatting the pen drive and also the command prompt window remain open always.
Suggest me what should I do to format my pen drive using vb.net code.
Thanks.
Gagan
|
|
|
|
|
Use the /c parameter switch to cmd.exe thus:
pr.StandardInput.WriteLine("/c format G:" & Convert.ToCha(13)) txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
Thanks for your reply, but I have still some doubt.
Could you explain that a little bit more?
Thnaks.
Gagan
|
|
|
|
|
Gagan.20 wrote: Thanks for your reply, but I have still some doubt.
Could you explain that a little bit more?
What more is there to explain? Open a command prompt window and type "cmd /?" for explanation of the switches and parameter options.txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
|
I have a doubt in the example you had suggested.
I am using a combo box to select drive name. In the code
Call SHFormatDrive(Me.hWnd, _
drvToFormat, _
SHFD_CAPACITY_DEFAULT, _
SHFD_FORMAT_QUICK)
where drvToFormat is declared as integer. When I am passing drive name to drvToFormat it is giving error that conversion from string to integer is not valid. What value should I paas as to drvToFormat to format my pen drive?
Thanks.
Gagan
|
|
|
|
|
You might want to read the documentation on SHFormatDrive[^]. You're passing in a string when you should be pass in a number. The number represents which drive to format. Read the documentation and you can figure out pretty easily, what that number is supposed to be.
|
|
|
|
|
Hi CP,
I am having a LineShape control with MouseDown,MouseUP,MouseMove events.
Dim fdragging As Boolean = False
Dim StartX, startY As Integer
Private Sub LineShape1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles LineShape1.MouseDown
fdragging = True
StartX = e.X
startY = e.Y
End Sub
Private Sub LineShape1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles LineShape1.MouseMove
If fdragging Then
LineShape1.StartPoint = New Point(LineShape1.StartPoint.X + e.X - StartX, LineShape1.StartPoint.Y + e.Y - startY)
LineShape1.EndPoint = New Point(LineShape1.EndPoint.X + e.X - StartX, LineShape1.EndPoint.Y + e.Y - startY)
End If
End Sub
Private Sub LineShape1_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ShapeContainer1.MouseUp
fdragging = False
StartX = 0
startY = 0
End Sub
Now i am not able to move the lineshape control freely around the form with cursor like in the design time .
Cursor is changing the location so slipping happens .
How to stick the cursor to LineShape control.
Regards,For1206
|
|
|
|
|
|
Hi Dave ,
Already i am having selections , The problem is on mousemove the line control is moving but if the cursor goes out of the line control its not handling the mousemove i.e, Slipping of Cursor on the cursor . I tried to set the cursor location on the control but not working fine .
Regards,For1206
|
|
|
|
|
You didn't read the article. The problem you're concentrating on handling the mouse move in the LineControl's events. DON'T! The mouse is actually moving in the parent container of the LineControl. This is why your code doesn't work.
|
|
|
|
|
Hi Dave ,
Thanks for reply & Thanks for the Link ,Presently i am using ur code in my application for changing the line startpoint and endpoint and dragging the line also.
Can u suggest me in a sample program that how can i move a LineShape control freely around the form with cursor without slipping .
This is happening in a sample new form.
This is the code i used & its slipping from cursor .
Dim fdragging As Boolean = False
Dim StartX, startY As Integer
Private Sub LineShape1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles LineShape1.MouseDown
fdragging = True
StartX = e.X
startY = e.Y
End Sub
Private Sub LineShape1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles LineShape1.MouseMove
Cursor.Current = Cursors.SizeAll
If fdragging Then
LineShape1.StartPoint = New Point(LineShape1.StartPoint.X + e.X - StartX, LineShape1.StartPoint.Y + e.Y - startY)
LineShape1.EndPoint = New Point(LineShape1.EndPoint.X + e.X - StartX, LineShape1.EndPoint.Y + e.Y - startY)
End If
End Sub
Private Sub LineShape1_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ShapeContainer1.MouseUp
fdragging = False
StartX = 0
startY = 0
End Sub
its important for me . plz can u suggest any work around ?
Regards,For1206
modified on Tuesday, February 23, 2010 1:57 AM
|
|
|
|
|
Read the article. I don't have time to write an entire sample app for you.
|
|
|
|
|
Hi Dave,
Thanks 4 reply . I already implemented your code in my application .Its made a nice job for me.
Thank you very much .
Regards,For1206
|
|
|
|
|
Hey All
I am having difficulty running a specific SQL statement in VB and was wondering if there is a way around it.
The problem I am having involves using "LIKE":
e.g. SELECT * FROM Table WHRE Field1 LIKE 'start*' (where start is the start of any text taken in as a parameter).
When I program an SQL statement like in VB, it won't yield the results I am looking for. I tested the code within SQL Server and MS Access Database and it works fine, but when I try again in the VB program, it yields no values.
The code does, however, work for "WHERE Field1 LIKE 'start'". So that means it has a problem with accepting the hash as part of the SQL query. I even tried using the VB character set within the SQL, but that too doesn't work.
Is there a way around this, or does VB not make use of the hash for an SQL statement?
Seems very weird to me.
Thanks for the help in advance!
|
|
|
|
|
Hi Evan
When using LIKE in SQL you should use the % character to indicate a wildcard character like this, SELECT * FROM Table WHERE Field1 LIKE 'Start%'. This works with Access databases as well as with MySql Databases, so should work with SQL Server.
Hope this helps
|
|
|
|
|
Hi
Thanks for the quick response...the '%' works perfectly.
Seems embarrassing for me to get stuck on such simple stuff when programming complicated systems sometimes.
Is there any reason why when using '*' works within each database but not when runnnig it through VB (or any other language) instead of '%'?
|
|
|
|
|
Because this is SQL syntax.
|
|
|
|
|
EvanSaunders wrote: SELECT * FROM Table WHRE Field1 LIKE 'start*'
Use % instead of *
SELECT * FROM Table WHRE Field1 LIKE 'start%'
|
|
|
|
|
|
VB does NOT use nor interpret any part of an SQL statement. All that state is to VB is just another String.
|
|
|
|