|
It's possible that the program is becoming deadlocked due to the user interface thread waiting on an object that never becomes signaled.
Run it in the debugger, and when it locks up, break into it to see where the main thread is.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
hi richard.. thanks for your post!
as I was unaware of what was causing the lock, i felt as though I wouldn't know where to put any break points in the script... BUT I had a rough idea..
it turned out that the file it was looping on was a temp file "~$*.txt" which is created then deleted and my program wasn't checking or handling this in any way - it just pauses if the move isn't possible then tries the process again..
extra code to report this as 'file not moved' or infact I may even just exit the sub as the reported temp files aren't of any interest anyway..
cheers for the basic yet helpful advise!!
tony
p.s. I previously had a cross threading problem with the application which I sorted using invoke.required.. I believe that is fixed now.... 99.9%
modified 17-Apr-14 7:20am.
|
|
|
|
|
am Try to doing how to display transparent flash files over a running video using msdxm or wmp control or is there any other way. i have done it using window less video but now video quality is lose is there any way to solve this problem
|
|
|
|
|
Hi, I'm feeling really stupid at the moment as i have spent days poring over code examples to no avail. I want to send a message received from a client to a textbox on a form here is an example of the code i've been attempting to modify
Imports System
Imports Microsoft.Samples.SharedInterface
Friend Class ImplementationClass
Inherits MarshalByRefObject
Implements ISharedInterface
Function HelloWorld(ByVal message As String) As String Implements ISharedInterface.HelloWorld
Console.WriteLine(("Client says: " & message))
Return "Hello to you too, client"
End Function
End Class
my understanding is that this code is run in a separate thread when this code implements it
Imports System
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting.Channels.Ipc
Module Module1
Sub main()
RemotingConfiguration.Configure("Server.exe.config", False)
Dim chan As IChannel
For Each chan In ChannelServices.RegisteredChannels
Console.WriteLine(chan.ChannelName)
Next chan
Console.WriteLine("Waiting for connections...")
Console.WriteLine("Press enter to exit.")
Console.ReadLine()
End Sub
End Module
I have moved the code out of sub main and into a form, where the form executes it on load, but that leave no reference to the thread or object from the interface. as a result i cannot use any data received through the interface beyond writing it to the console. i cannot directly reference the form in the implementation class and without a link to the form i cannot even use a delegate. any suggestions would be greatly appreciated.
|
|
|
|
|
Hi,
In all the Microsoft examples I've seen, the server is dumb, i.e. it does not interact with the remotable objects. This fairly common requirement is quite easy to implement, once you know how. The trick is to create a standard object on the server and then publish it for remoting using System.Runtime.Remoting.RemotingServices.Marshal .
Here's the example based on that MS ISharedInterface
Public Interface ISharedInterface
Function HelloWorld(input As String) As String
End Interface
This is the remotable class, implementing the interface, which will be created as a local object on the server. For simplicity in the example I just pass a reference to a TextBox to the constructor. The HelloWorld function executes on a non UI thread and has to Invoke the TextBox.
Public Class MessageReceiver Inherits MarshalByRefObject Implements ISharedInterface
Private ReadOnly log As TextBox
Private Delegate Sub Update(text As [String])
Public Sub New(log As TextBox)
Me.log = log
End Sub
Public Function HelloWorld(input As String) As String
log.Invoke(New Update(AddressOf UpdateTextBox), input)
Return input
End Function
Private Sub UpdateTextBox(text As [String])
log.AppendText(text)
log.AppendText(Environment.NewLine)
End Sub
Public Overrides Function InitializeLifetimeService() As Object
Return Nothing
End Function
End Class
Now we have the 'abbreviated' form class which is the UI for the server. In it I haven't shown the declaration for a multiline TextBox named logTextBox. The important stuff is the creation of a local object followed by separate 'remoting'. Most MS examples use tcp but I've configured for ipc as that is more appropriate for process to process communication on a single machine.
Public Partial Class MainForm Inherits Form
Private server As IpcServerChannel
Private receiver As MessageReceiver
Protected Overrides Sub OnShown(e As EventArgs)
MyBase.OnShown(e)
receiver = New MessageReceiver(logTextBox)
server = New IpcServerChannel("IpcPortName")
ChannelServices.RegisterChannel(server, False)
logTextBox.AppendText("IpcServerChannel created")
logTextBox.AppendText(Environment.NewLine)
RemotingServices.Marshal(receiver, "ServerObject.rem")
End Sub
End Class
Finally for completeness there is a console based client which fires a few messages at the server.
Public NotInheritable Class ClientApp
Private Sub New()
End Sub
Private Shared remoteObject As ISharedInterface
Public Shared Sub Main(args As String())
Try
remoteObject = DirectCast(Activator.GetObject(GetType(ISharedInterface), "ipc://IpcPortName/ServerObject.rem"), ISharedInterface)
For i As Int32 = 0 To 4
Console.WriteLine(" " & remoteObject.HelloWorld("Hi Server " & i))
Thread.Sleep(2000)
Next
Catch re As System.Runtime.Remoting.RemotingException
Console.WriteLine(re)
End Try
Console.WriteLine("Press enter to end...")
Console.ReadLine()
End Sub
End Class
All that code was converted from c# with http://www.developerfusion.com/tools/convert/csharp-to-vb/[^] so I'm not totally to blame if it doesn't work!
Alan.
|
|
|
|
|
Thank you so much for your reply. With some minor changes I got the code working. Here is the final result.
The MS ISharedInterface in a class library referenced by both the server and the client.
Public Interface ISharedInterface
Function HelloWorld(input As String) As String
End Interface
The message receiver in the windows forms project for the server
Imports SharedInterface
Imports System.Windows.Forms
Public Class MessageReceiver
Inherits MarshalByRefObject
Implements ISharedInterface
Private ReadOnly log As Textbox
Private Delegate Sub Update(text As [String])
Public Sub New(log As TextBox)
Me.log = log
End Sub
Public Function HelloWorld(input As String) As String Implements ISharedInterface.HelloWorld
log.Invoke(New Update(AddressOf UpdateTextBox), input)
Return input
End Function
Private Sub UpdateTextBox(text As [String])
log.AppendText(text)
log.AppendText(Environment.NewLine)
End Sub
Public Overrides Function InitializeLifetimeService() As Object
Return Nothing
End Function
End Class
The Form for the Server i used was just the standard form. i added a textbox and made it multiline in the form designer. here is the code
Imports System.Windows.Forms
Imports System.Runtime.Remoting.Channels.Ipc
Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting
Public Class Form1
Private server As IpcServerChannel
Private receiver As MessageReceiver
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
receiver = New MessageReceiver(logTextBox)
Server = New IpcServerChannel("IpcPortName")
ChannelServices.RegisterChannel(Server, False)
logTextBox.AppendText("IpcServerChannel created")
logTextBox.AppendText(Environment.NewLine)
RemotingServices.Marshal(receiver, "ServerObject.rem")
End Sub
and finally the client in its own console application
Imports SharedInterface
Imports System.Threading
Public NotInheritable Class ClientApp
Private Sub New()
End Sub
Private Shared remoteObject As ISharedInterface
Public Shared Sub Main(args As String())
Try
remoteObject = DirectCast(Activator.GetObject(GetType(ISharedInterface), "ipc://IpcPortName/ServerObject.rem"), ISharedInterface)
For i As Int32 = 0 To 4
Console.WriteLine(" " & remoteObject.HelloWorld("Hi Server " & i))
Thread.Sleep(2000)
Next
Catch re As System.Runtime.Remoting.RemotingException
Console.WriteLine(re)
End Try
Console.WriteLine("Press enter to end...")
Console.ReadLine()
End Sub
End Class
Again, Many thanks for the example you coverted, and the prompt reply.
|
|
|
|
|
I'm creating a software package that we are deploying to multiple employees at one of our client's sites. This software is designed to gather system information (OS, 32/64-bit, machine name, etc.) and also check whether N-able and Lync Basic 2013 is installed, and install them if necessary.
Currently both the N-able and Lync installation packages are embedded within my assembly. If the user is missing either program, the file will be extracted and ran silently without any user input. The issue I'm running into is that the N-able installation requires admin privileges. All the computers have the same admin account (we set it up that way; they don't have a central server/domain) and I'm trying to have the N-able run under that account so that way the user is prompted with any messages.
From everything I've been reading it seems that I have to create some kind of intermediate program that my program runs, which then can run the N-able silent installation using the admin account. However I haven't been able to find any good tutorials/step-by-step guides on how to do this?
Anybody have any links to guides on how I can do this. I just need to know how I can start another process using the credentials of an admin account that I already know; the users don't know these credentials so I can't have them type them in. I have tried using Process.Start with various settings, CreateProcessAsUser, CreateProcessWithLogonW, etc. but they all give me errors such as "This operation requires elevated permissions, "A required privilige is not held by the client", etc. It doesn't matter if I do it through the .NET Framework, P/Invoke, or a separate library, as long as the guide instructs me how I can use it from my assembly it's good.
Any help that you can provide will be greatly appreciated...I'm supposed to have this finished within the next day or two. Thank you a lot in advance.
A black hole is where God tried to divide by zero.
There are 10 kinds of people in the world; those who understand binary and those who don't.
|
|
|
|
|
Do it differently. Instead of installing the required third party programs when your program is started by a user, install them during the installation process of your program - since the installation is run by a System account, that will work.
|
|
|
|
|
My program doesn't need to be installed. It is a single executable that I'm placing the client's DropBox folder and then sending a link to everyone. This way they can just click the link and the program will run without requiring any user interaction.
A black hole is where God tried to divide by zero.
There are 10 kinds of people in the world; those who understand binary and those who don't.
|
|
|
|
|
Well, therein lies the problem.
What you're talking about doing is a security risk. In order for your code to be able to do what you want to, you have to ship the username and password for an Admin account with the code, to all of the users. That's a big no-no. You're exposing yourself and the company to security risk by doing that.
Also, what if the admin account username/password changes? Now you have to update the code to use the new ones! Worse yet, what if the username/password changes on some machines and not others?? Now you're screwed.
The proper way to do it is to come up with an install package for your prereqs and install those before the user launches the application, not after they launch it.
|
|
|
|
|
Agreeing with Dave, it's a security risk.
But have a look at the Process.StartInfo Class. There you can use username and Password to run a new process.
|
|
|
|
|
We are aware of the possible security risk but my company considered it extremely low. My company wants an application that is a single file, does not require an installation, is able to gather some basic computer information, as well as install two other programs. One of those two programs need admin privileges to install.
I have tried using the Process.StartInfo class with username and password but I still get an exception about the installation of one of the programs needing elevated privileges.
The chances of anyone being able to disassemble the assembly to get the admin info is very remote and even if they did get it they couldn't really do any harm with it. The computers aren't on a domain; we create the account on the computers so that way the users can't just install any software on their computers or just do any updates they want. Plus there isn't any server at their site that they would get access to should they somehow get the credentials, or any kind of shared resources (except the DropBox admin account which uses different credentials). In addition, once the program does what it is supposed to do, the file deletes all traces of the program.
I know this isn't the best way to go about it, but for what my company is looking for (a single file that is fully automated, thereby not needing any IT intervention to input the credentials) this is the only way I could think of doing it. As an extra layer of precaution I did implement a very simple encryption algorithm so if somehow they did disassemble the file they wouldn't just see a plaintext password.
A black hole is where God tried to divide by zero.
There are 10 kinds of people in the world; those who understand binary and those who don't.
|
|
|
|
|
Try Process.StartInfo.Verb="runas". This is a directive to elevate UAC privilegies, ie to allow a UAC limited admin account full rights. This verb also requires UseShellExecute=True.
|
|
|
|
|
I've been working on this for over an hour now. I get the "No value given for parameter" message on exception
If I take the WHERE statement out, it works fine. If I replace the value in the parameter with a hard coded date, I get the error as well. I added a watch to the command, and I can see the parameter attached with the value.
It's an old foxpro / clipper database, so maybe I need to make some adjustments.
Public Function load_am_Invoices( _
ByVal p_currentDate As DateTime) As Integer
Dim dwExitCode As Integer = 2
Dim connString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=D:\amp\sis1; Extended Properties=dBASE IV"
Dim queryString As String = _
"SELECT * " & _
"FROM ARCUS01.dbf " & _
"WHERE FORDATE=@startDate"
Dim connection As New System.Data.OleDb.OleDbConnection(connString)
Dim command As New System.Data.OleDb.OleDbCommand(queryString, connection)
Dim paramStartDate As System.Data.OleDb.OleDbParameter
paramStartDate = New System.Data.OleDb.OleDbParameter("@startDate", OleDbType.DBDate)
paramStartDate.Value = p_currentDate
command.Parameters.Add(paramStartDate)
Try
connection.Open()
Dim reader As System.Data.OleDb.OleDbDataReader = command.ExecuteReader()
While reader.Read()
End While
reader.Close()
connection.Close()
Catch ex As Exception
dwExitCode = 1
End Try
dwExitCode = 0
Return dwExitCode
End Function
|
|
|
|
|
I got the column name wrong, missing 1 D char FORDDATE not FORDATE
[EDIT]
I must admit that the error message text was misleading, making me look for the parameter value
modified 15-Apr-14 12:30pm.
|
|
|
|
|
Always good when you solve your own issue; even better when you post the solution.
|
|
|
|
|
I stumbled on the answer by accident, fixing something else after the post. The old I could of had a V8 Juice
|
|
|
|
|
Dim directory = "c:\yeni"
Dim dosyalar() As System.IO.FileInfo
Dim dirinfo As New System.IO.DirectoryInfo(directory)
dosyalar = dirinfo.GetFiles("*", IO.SearchOption.AllDirectories)
For Each dosya In dosyalar
ListBox1.Items.Add(dosya)
i get directory info and fileinfo there are 2 csv files in folder
the i copy it to
Dim parser As New FileIO.TextFieldParser(dosyalar)
it doest go to parse function
|
|
|
|
|
sensizbenlik wrote: it doest go to parse function
It might be going out back for a smoke. I suspect that the debugger will tell you for sure.
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
You really should go read the documentation for the classes that you are trying to use. None of the overloads for the TextFieldParser constructor take an array of System.IO.FileInfo objects.
|
|
|
|
|
i do it
For Each f As FileInfo In dosyalar
Dim parser As New FileIO.TextFieldParser(f.FullName)
|
|
|
|
|
Okay.... and then what happened?
It would really help speed things along if you just tell us what it is that your code is doing. We can't see your code or your screen to know what is going on. It would also help if you posted your real code.
|
|
|
|
|
when clicking the button code is getting all csv files from the folder to database. in the folder csv files have 3 columns. but contents are different
|
|
|
|
|
Well considering that I have no idea what CSV files you are talking about, what database you are talking about or what
sensizbenlik wrote: but contents are different
means and since you do not provide the information required to help, I am at a loss as to what you expect people to do for you.
|
|
|
|
|
Hi,
I've been searching for some examples of TCP client application. The setup is not a regular server/client.
I've a serial to ethernet converter (Moxa or Ewon device) which act like a server. The device is sending data on an independant time base. I need to grab that data and analyze it. I can open the connection on a particular port, but don't know how to receive the data.
Somebody can give some advise.
Thx,
Kurt
|
|
|
|