|
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
|
|
|
|
|
|
I am currently working on a project to exchange data by using a web service. Do work with the web service, the owner of the web service has given me a WSDL file. However, when I read-in this file in Visual Studio 2010 as a service reference, then no routines are created in the Reference.vb. In other situations that I used a WSDL file and added it as a service reference, that was the case. Can anyone give me advice on how I can use this WSDL to exchange data with the web service? I am using VB.NET to make the connection.
|
|
|
|
|
Again, I have a question on my homework this week. When I run my code, it doesn't list the races/results in order. What am I doing wrong?
Dim chevy(8) As Decimal
Dim ford(8) As Decimal
Dim chevyCount As Integer = 0
Dim fordCount As Integer = 0
Dim index As Integer = 0
For index = 0 To 7
Console.WriteLine("Enter Chevy " & (index + 1) & " : ")
chevy(index) = Console.ReadLine()
Next
Console.ReadLine()
For index = 0 To 7
Console.WriteLine("Enter Ford " & (index + 1) & " : ")
ford(index) = Console.ReadLine()
Next
Console.ReadLine()
For index = 0 To 7
If (chevy(index) < ford(index)) Then
chevyCount = chevyCount + 1
Console.WriteLine("Chevy won by " & ford(index) - chevy(index) & " . ")
Console.WriteLine("Chevy has won " & chevyCount & " races.")
End If
Next
For index = 0 To 7
If (chevy(index) > ford(index)) Then
fordCount = fordCount + 1
Console.WriteLine("Ford won by " & chevy(index) - ford(index) & " . ")
Console.WriteLine("Ford has won " & fordCount & " races.")
End If
Next
For index = 0 To 7
If (chevy(index) = ford(index)) Then
chevyCount = fordCount
Console.WriteLine("This race was a tie!")
End If
Next
Console.ReadLine()
If chevyCount > fordCount Then
Console.WriteLine("Chevy wins the match!")
Else
Console.WriteLine("Ford wins the match!")
End If
Console.ReadLine()
End Sub
|
|
|
|
|
Member 10728667 wrote: it doesn't list the races/results in order
You are going to explain what it is that you mean. Of course it lists them in order. It would really help us if you gave some idea of the input that you used, the output that you got and why the output is not what you expected it to be. Quite frankly without knowing what it is that you are trying to do here, it's really hard to figure out. But I can tell you that your code is doing exactly what you told it to do.
|
|
|
|
|
I have taken a quick look:
1. change those
Console.ReadLine()
after every Next's to
Console.WriteLine()
2. There is a logical error here, find and fix it yourself:
For index = 0 To 7
If (chevy(index) < ford(index)) Then
chevyCount = chevyCount + 1
Console.WriteLine("Chevy won by " & ford(index) - chevy(index) & " . ")
Console.WriteLine("Chevy has won " & chevyCount & " races.")
End If
Next
3. You have missed out one more condition in:
If chevyCount > fordCount Then
Console.WriteLine("Chevy wins the match!")
Else
Console.WriteLine("Ford wins the match!")
End If discover and add it yourself.
|
|
|
|