|
I would like to know how to accomplish the following goals in C#:
1. In an existing C# 2008 application, I would like to create two separate log files.
a. The first log file would write out data in a fixed file format prferably to a text file. A new C# 2010 desktop and/or console application would be written to read this file and do furher processing.
b. The second log file would be written to display any messages generated by the console application and/or messages that are generated by a web service the console application calls.
Can you show me how to create these two log files?
2. A new C# 2010 desktop and/or console application will be written to process the information contained with the log file produced in a fixed file format in step 1a. listed above.
Can you show me how to read the log file that is in a text file fixed format?
Can you tell if the log file generated in a fixed file format should be generated in another format besides text? If so, what format should be used and can you tell me how to read the data in this alternative file format?
|
|
|
|
|
sc steinhayse wrote: Can you tell if the log file generated in a fixed file format should be generated in another format besides text?
No, plain old text format will be sufficient.
sc steinhayse wrote: Can you show me how to read the log file that is in a text file fixed format?
A google search on basic file I/O in C# would be a good starting place.
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
You can use Log4Net to generate a log for an application. Go through their documentation to figure out how to use it.
|
|
|
|
|
Hello everyone,
I need to write a method in C# that can be called from VBA using COM. The primitive types can be directly passed to the method and returned from it, but what about the complex types? For instance, the C# List<> will have to be converted in a VB Collection.
Thanks, in advance,
Mark
|
|
|
|
|
mark4 wrote: The primitive types can be directly passed to the method and returned from it, but what about the complex types? For instance, the C# List<> will have to be converted in a VB Collection.
Have you considered switching from VBA to PowerShell? That way you'd be able to use the complex types from the script.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
I can't, I have to use C#.
|
|
|
|
|
To replace the VBA part, not the C#-part; it's got a bit better support for .NET.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
I can't either. lol I'm struggling to find a simple tutorial on how to make a COM class to exchange bewteen applications. I'm not familiar at all with COM.
|
|
|
|
|
If I remember correctly, the List and List<t> types are not COM-visible. You cannot use them from VBScript and use them as return values to VBScript. You would have to replace them with Array equivelents.
You would have to convert all of your comlex return values/types down to simpler types that VBScript is familiar with.
|
|
|
|
|
First, I'm not using VBScript but VBA. Second, it's not so easy, my C# method must return a binary tree. So it can't be represented with primitive types.
|
|
|
|
|
mark4 wrote: First, I'm not using VBScript but VBA
Does not matter. You have the same limitations.
mark4 wrote: Second, it's not so easy, my C# method must return a binary tree.
OK, so you're going to have to represent your binary tree in a format that's more portable acrossed COM.
|
|
|
|
|
That's right, so my question is: how to do it? I've gone thru several tutorials but I find them very difficult and they are too specific to an example. Do I need to create an interface? How do I generate GUIDs? Well, I have many questions... If you know a good and simple tutorial, if would help me.
|
|
|
|
|
I don't know of any "simple" tutorials on this.
One design I would look at is a class in C# that manages the view of the tree that your VBA code sees. Basically giving the VBA code methods it can use to nagivate the tree and return the values contained in a specific node in the tree. Returning the entire tree is just silly.
|
|
|
|
|
Hi.
I am getting the following error:
Object reference not set to an instance of an object.
here is my code:
private StringBuilder data_changed = new StringBuilder();
.....
.....
if (full_name != txtFullName.Text) data_changed.Append(String.Format(" - name: {0} -> {1}", full_name, txtFullName.Text)).AppendLine();
|
|
|
|
|
Put a break point on your if statement and examine the data you're working with when it's hit.
My guess is full_name is probably null...
|
|
|
|
|
|
This error occurs when you try and access a property of an object that is already null.
Debug and figure out which of the values is throwing this error.
|
|
|
|
|
This is probably the easiest of all .Net exceptions to debug. One of the things you're trying to reference is null. On that line you have only txtFullName and data_changed being dereferenced, so it must be one of those. Work out which one it is and either change the calling context or null-protect this code.
|
|
|
|
|
i found the problem. there was a:
data_changed = null;
I removed it and code is working fine.
Thanks everyone
|
|
|
|
|
I have a question about how to obtain the results from a web service
Basically I have received a C# console application code that calls a remote webservice and consumes the results. The console application runs by giving it commands to know what method in the web service to call.
Now I am going to write a C# 2010 service application that will call the C# 2008 console and run the commands in a specificed order.
Basically the steps would be:
1. write the new .net app to make callls in a sequential order to a console app progrm.
2. The console application calls the web service and obtains the results,
3. The new .net app obtains the results of the web service from the console application it called.
Let me know how I can accomplish my goal with code and/or references.
|
|
|
|
|
Why don't you directly consume the web service in the new application? That would be the easiest to do.
|
|
|
|
|
I do not want to change the console application that was written by the contract shop unless I need to for the following reasons:
1. There are alot of edits in the *.xsd that was written by the contract shop. I do not know how to tell how these edits are tied to the application. is there a way that I can tell how the edits are tied to the console application?
2. It is extremely hard to get ahold of the contract shop and to ask them questions. The customer that pays both of us, is in charge of how we communicate with this contract shop. There is alot of red tape to ask the contract shop any question.
|
|
|
|
|
How did you plan on sending "commands" to a console-app?
dcof wrote: Let me know how I can accomplish my goal with code and/or references.
Aight.. easiest way would be to have the "commands" in a separate text-file. Makes it easy to modify, and you can loop the lines easily after reading all text.
The loop could use a Console.ReadLine to get a command (read it from the file later), use a switch to see what should be done, print the results to the console.
What type of command? Can you give an example with three commands? Do they have parameters?
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Right now I can entering the values in a command window and clicking on the command to execute the code. In the new .net application, I plan on running these commands based on the sequence of commands the application is setup to run.
The commands do have paramters. The parameters are the location of the webservice followed by the type of command that needs to be executed.
|
|
|
|
|
You have talked around this app several times over the last few days. It's obvious that you can't do what you're trying to do, which should tell you that your architecture is wrong. Why aren't you directly consuming the service?
|
|
|
|