|
Just a suggestion....
make each end a wcf endpoint
set the attributes to use NamedPipes
pass the data over the wcf pipline
|
|
|
|
|
Hi everyone, i wanted to know if someone here knows where could i find some tutorials to accomplish the following:
I want to make a silverlight app that shows in a main screen a pictures of a room, let´s say a living room, and i want to have a small menu at the left with a scroll bar with different things in it(different lamps, flowers, candels, etc.) and what i want to do is to drag and drop the desired element and place it into the main picture (living room).
Im pretty much a newbie so any tutorial that you can point at will be really usefull.
Thanks in advanced.
modified 6-Apr-22 21:01pm.
|
|
|
|
|
Whilst you may get an answer from somebody here, you would be better to post this in the Silverlight Forum.
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.”
|
|
|
|
|
First, let me say that I am not a C# programmer. Complete newb here... Don't hate me because I'm beautiful...
I am trying to create a drop-dead simple application that will set a function callback address in the C++ COM dll to point to a C# function in the demo application. (This is for a sample application to demonstrate our API to potential users.) I have it working for both C++ and Visual Basic, but thus far, C# success is eluding me.
Here is what I have done...
Created a simple form with three text boxes that will be filled with XYZ values when everything works.
Within the namespace of my app (TestCSharpApp... so I lack imagination... sue me...) I have created a delegate function like this.
public delegate void coordCallbackFunction(double x, double y, double z, int buttonNumber );
In my public partial class Form1 : Form class, I have the function I want to call.
public void coordHandler(double x, double y, double z, int buttonNumber)
{
xCoord.Text = x.ToString();
yCoord.Text = y.ToString();
zCoord.Text = z.ToString();
}
Finally, In the form load function I have this code.
MyCOMInterfaceLib.MyCOMClassClass myApi = new MyCOMInterfaceLib.MyCOMClassClass();
myApi.coordCallback += new coordCallbackFunction(this.coordHandler);
I realize that myApi will go away right after setting up the callback, but I am just trying to get it to compile. I'll worry about details later.
When I compile the program I get this error...
Error 1 Cannot implicitly convert type 'TestCSharpApp.coordCallbackFunction' to 'MyCOMInterfaceLib._IMyCOMClassEvents_coordCallbackEventHandler' C:\Temp\TestCSharpApp\Form1.cs 38
I have included the MyComInterfaceLib in my list of references. I can call functions from the COM dll and that works fine. The problem is setting the callback function using delegates.
It may not mean much, but the callback functions work fine in VB.Net, so I don't think the problem is in the COM dll.
Thank you for any help.
|
|
|
|
|
I really don't like answering my own questions...
Apparently C#, unlike VB, automatically creates delegates for COM events. So instead of creating my own function I use theirs.
Code then becomes,
myApi = new MyCOMInterfaceLib.MyCOMClassClass();
myApi.coordCallback += new _IMyCOMClassEvents_coordCallbackEventHandler(this.coordHandler);
If there is a better or easier way to do this, please let me know.
Otherwise, thank you.
- Matt
|
|
|
|
|
I have a DataGridView. I am in need of adding additional properties to each row. I would assume this would consist of extending the DataGridViewRow class.
If my assumption is correct, how would I implement this class so that when adding rows to the datagridview, each row is created as a ExtendedDataGridViewRow rather than a DataGridViewRow.
If I am completely heading in the wrong direction, what would be a better way of accomplishing my goal?
Thanks in advance!
|
|
|
|
|
theallmightycpd wrote: I have a DataGridView. I am in need of adding additional properties to each row.
You seem to have already decided how to proceed.
theallmightycpd wrote: If I am completely heading in the wrong direction, what would be a better way of accomplishing my goal?
Or maybe not.
Seriously, it will be very difficult for anyone to advise you accurately because you have not described what it is you are trying to do. Forget about the 'extending DataGridViewRow' stuff and describe the problem that made you decide that that is the way to go in the first place.
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.”
|
|
|
|
|
First of all, I want to add a filter to the datagridview. I have completed this step by adding dropdowns to the column headers that populate with that columns values (uniquely). When a row does not match the current filter, its visibility is set to false.
Next, I want to add the ability to expand and collapse similar rows. For instance, if Row A contains the values {Test,1,2,3} and row B contains that values {Test,A,B,C}, the row can be collapsed into a header row with just the value {+,Test}. The plus symbol would be used to expand back into the two rows. A - on the header row will collapse back in to just the single row. When rows are collapsed, I am setting their visibility to false, also.
Currently, these features work separately, but do not work together. When a row's visibility is false, I don't know if it's because it doesn't match the filter or if the row is collapsed. What I would like to do is to add additional properties to each row describing when it is a row included or excluded in the current filter and another property for the expand/collapse header rows describing how many rows are assosicated with that header.
I hope this makes my intentions clearer.
|
|
|
|
|
What you are trying to do sounds a little like a cross between a TreeGridview[^] and OutlookGrid: grouping and arranging items in Outlook style[^].
I hope that the links above will at least give you some ideas, if you haven't seen them before.
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 working on my first C# project, first real programming in a while. Not exactly like riding a bike...
I'm trying to create a class or struct that contains a StringBuilder. Truthfully, either class or struct, either string or StringBuilder should work OK, but a class with StringBuilder seems like the *right* solution. But I get errors.
Here is the class:
public class sheetCols
{
string colHdg;
public string colLetter;
public StringBuilder colValue = new StringBuilder(" ");
public sheetCols(string s1, string s2, string s3)
{
this.colHdg = s1;
this.colLetter = s2;
this.colValue.Length = 0;
this.colValue.Append(s3);
}
}
The error I see on the constructor is:
Field 'RAContractToolConsole.Program.sheetCols.colValue' must be fully assigned before control is returned to the caller
The warning on the Length assignment is:
Use of possibly unassigned field 'colValue'. Struct instance variables are initially unassigned if struct is unassigned.
I looked around on CodeProject and elsewhere online; can't find an answer. One post alluded to a bug in VS, but that was v7, and I'm on VS2008 (aka v9), updated according to Windows Update.
What am I missing? Is it possible to use a StringBuilder inside another class? I couldn't find an example online.
Thanks in advance.
|
|
|
|
|
Hi,
when sheetCols is a class (as in your snippet), the code is fine.
when sheetCols is a struct, it would not be OK:
- you can't have initializers on struct members;
- every consrtuctor needs to initialize all data members.
Here are some suggestions for you:
- tell your IDE to always show line numbers in editor windows (see here[^]);
- watch the squiggly lines (red or green) Visual Studio uses to flag problems;
- watch the errors and warnings any IDE will produce; and focus on the first one first; you must get rid of all errors before you can execute, and it is wise to also get rid of the warnings.
- be meticulous; every single keyword and punctuation mark matters.
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Thanks, Luc. I changed my settings like you suggested. Good ideas.
Now I'm really scratching my head. Did nothing more than save the files and exit VS. Now when I went back to look at the errors again, since you said it should work, THEY ARE GONE! But I didn't change any code.
I don't get it. I've seen other inconsistencies. I have a couple of objects declared and instantiated at the beginning of the program, and I get errors that they are unassigned local variables. But if I start the build, those 2 errors disappear from the error list, and the program runs as expected.
|
|
|
|
|
Hi,
some comments on Visual Studio:
1. there are a lot of settings, so behavior may be different on different machines;
2. there is some background checking going on, so warnings/errors may come and go while you edit, without explicitly invoking a compilation;
3. the "Error List" pane lags your editing, it may still be showing the results from the latest build.
4. under menu Tools/Options/Build and Run, there is a setting "On run when there are errors..." I strongly recommend "do not run" as opposed to "run older version" as this is really confusing.
Hope this helps.
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
What happens if a thread call a method and find a blocked code area inside this method (with lock, Monitor ...) if follow with the rest of the method don´t blocked or stay waiting in the initious of the blocked area until the thread inside the block release it ?
Regards
|
|
|
|
|
It waits until the lock releases.
|
|
|
|
|
Hello,
I Am using the following functions to encrypt and decrypt files:
Encrypt:
private void EncryptFile(string inputFile, string outputFile)
{
try
{
string password = @"19651969";
UnicodeEncoding UE = new UnicodeEncoding();
byte[] key = UE.GetBytes(password);
string cryptFile = outputFile;
FileStream fsCrypt = new FileStream(cryptFile, FileMode.Create);
RijndaelManaged RMCrypto = new RijndaelManaged();
CryptoStream cs = new CryptoStream(fsCrypt,
RMCrypto.CreateEncryptor(key, key),
CryptoStreamMode.Write);
FileStream fsIn = new FileStream(inputFile, FileMode.Open);
int data;
while ((data = fsIn.ReadByte()) != -1)
cs.WriteByte((byte)data);
fsIn.Close();
cs.Close();
fsCrypt.Close();
}
catch
{
MessageBox.Show("Encryption failed!", "Error");
}
}
Decrypt:
private void DecryptFile(string inputFile, string outputFile)
{
{
string password = @"19651969";
UnicodeEncoding UE = new UnicodeEncoding();
byte[] key = UE.GetBytes(password);
FileStream fsCrypt = new FileStream(inputFile, FileMode.Open);
RijndaelManaged RMCrypto = new RijndaelManaged();
CryptoStream cs = new CryptoStream(fsCrypt,
RMCrypto.CreateDecryptor(key, key),
CryptoStreamMode.Read);
FileStream fsOut = new FileStream(outputFile, FileMode.Create);
int data;
while ((data = cs.ReadByte()) != -1)
fsOut.WriteByte((byte)data);
fsOut.Close();
cs.Close();
fsCrypt.Close();
}
}
I'm using the following code to Decrypt my encrypted file, read it, then encrypt it again.
private void Form1_Load(object sender, EventArgs e)
{
if (File.Exists("scf.sf"))
{
DecryptFile("scf.sf", "sff.sf");
File.Delete("scf.sf");
File.Move("sff.sf", "scf.sf");
TextReader encryptRead = new StreamReader("scf.sf");
string encryptionCheck = encryptRead.ReadToEnd();
encryptRead.Close();
if (encryptionCheck.Contains("locked"))
{
MessageBox.Show("**yayaya***", "BlaBla", MessageBoxButtons.OK, MessageBoxIcon.Stop);
EncryptFile("scf.sf", "ssf.sf");
File.Delete("scf.sf");
File.Move("ssf.sf", "scf.sf");
Application.Exit();
}
}
else
{
MessageBox.Show("Component Corrupt, Application Will Now End.", "Slyther Security Runtime", MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Exit();
}
EncryptFile("slcf.sf", "slcfc.sf");
File.Delete("slcf.sf");
File.Move("slcfc.sf", "slcf.sf");
}
However, whenever I run it:
while ((data = cs.ReadByte()) != -1)
IndexOutOfRangeException was Unhandled.
Index was outside the bounds of the array.
This worked fine last night, and im not quite sure how i've tweaked the code to make it stop working. I'm going to continue looking into it while I wait for a reply.
Thanks,
Ben.
modified on Monday, September 21, 2009 12:41 PM
|
|
|
|
|
Oops, My bad, i'd replaced the file so many times in testing I forgot to encrpypt it again
|
|
|
|
|
Hi everybody,
Now, I have to create a Word file from a word template, i have faced a difficult problem when replace a text on Word file.
In my file Word template, I have 5 lines with the text is "Name_of_Applicant". (Please note that the BOOKMARK will not use in this template)
In my C# code, I would like to do as follows:
1. Find the text "Name_of_Applicant" and Replace it.
2. I do Foreach(Word.Range tmpRange in oWordDoc.StoryRanges) { ... do something ... }. In the FOR loop, I will replace 5 lines as "Name_1", "Name_2", .... , "Name_5".
private void OpenWord_Click(object sender, EventArgs e)
{
object oMissing = System.Reflection.Missing.Value;
oWord = new Word.Application();
oWordDoc = new Word.Document();
oWord.Visible = true;
oWord.NormalTemplate.Saved = true;
oTemplatePath = "D:\\Template.doc";
oWordDoc = oWord.Documents.Open(ref oTemplatePath, ref oMissing, ref readOnly, ref readOnly, ref oMissing, ref oMissing, ref readOnly, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
object findText = "Name_of_Applicant";
try
{
int index_name = 0;
object oReplace = "Name_" + index_name.ToString();
foreach (Word.Range tmpRange in oWordDoc.StoryRanges)
{
if (oWord.Application.Selection.Find.Execute(ref findText, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oReplace, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing))
{
index++;
}
}
}
catch
{
MessageBox.Show("The text could not be located.");
}
}
The code above is only one of many different way that I have tried, but I have only replace the FIRST line.
Do you have any idea for this problem. It's will be appreciate your help so much.
Thank you
|
|
|
|
|
I need some help and I hope I have placed this is the correct forum.
I was asked by my employer to write an application to integrate a call recording system with a CSR issue tracking system. A customer calls in and the CSR handles the issue in the issue tracking software while at the same time a call recorder server is recording the call. My application tags the call database record with a unique id and passes it to the issue tracking software to allow administrators to later review the call recordings by clicking a link in the issue tracking software. When the link is clicked the unique call tag is passed back to my software by means of TCP sockets as in the code below to retrieve the call recording and play it to the user. I have wired an event in my code to the MessageRead event in this class. Everything works as planned EXCEPT: My problem is that when I include this class in my application I get random and frequent abends of the application with absolutely no indication of what the exception may be which caused it. I have turned on all exceptions in the debugger and tried to handle all exceptions outside of this class. This code was supplied to me by the company who wrote the issue tracking software so I have been reluctant to do anything inside their code, but at this point I am willing to try any suggestions. Their support has been to wait for us to resolve this (although I do hope and believe they are working on this on their side as well).
Any and all help is appreciated.
JLP
using System;
using System.ComponentModel;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.Xml;
using System.Windows.Forms;
namespace CallRecordingServer
{
public class MessageReceiver
{
int tcpPort;
private BackgroundWorker tcpThread = new BackgroundWorker();
public delegate void ReadHandler(string MessageType, string MessageText);
public event ReadHandler MessageRead;
public MessageReceiver()
{
tcpPort = Convert.ToInt32(TaskTrayApplication.Properties.Settings.Default.tcpPort);
tcpThread.WorkerReportsProgress = true;
tcpThread.WorkerSupportsCancellation = true;
tcpThread.DoWork += Thread_DoWork;
tcpThread.ProgressChanged += tcpThread_ProgressChanged;
}
public void StartListening()
{
try
{
if (!tcpThread.IsBusy)
{
tcpThread.RunWorkerAsync();
}
}
catch (Exception ex)
{
MessageBox.Show("MessageReceiver", ex.Message);
}
}
public void StopListening()
{
tcpThread.CancelAsync();
Thread.Sleep(200);
}
void Thread_DoWork(Object sender, System.ComponentModel.DoWorkEventArgs e)
{
IPAddress ipLocalhost = IPAddress.Any;
TcpListener tcpListener = new TcpListener(ipLocalhost, tcpPort);
try
{
tcpListener.Start(100);
while (!tcpThread.CancellationPending)
{
while (!tcpListener.Pending() && !tcpThread.CancellationPending)
{
System.Windows.Forms.Application.DoEvents();
Thread.Sleep(10);
}
if (tcpThread.CancellationPending)
{
break;
}
TcpClient tcpClient = tcpListener.AcceptTcpClient();
NetworkStream netStream = tcpClient.GetStream();
StreamReader netStreamReader = new StreamReader(netStream);
StreamWriter netStreamWriter = new StreamWriter(netStream);
netStreamWriter.AutoFlush = true;
string stringData;
stringData = netStreamReader.ReadToEnd();
tcpThread.ReportProgress(0, stringData);
netStreamReader.Close();
netStream.Close();
tcpClient.Close();
}
}
catch (Exception ex)
{
MessageBox.Show("MessageReceiver",ex.Message);
tcpThread.ReportProgress(100, e);
}
finally
{
tcpListener.Stop();
}
}
void tcpThread_ProgressChanged(Object sender, System.ComponentModel.ProgressChangedEventArgs e)
{
if (e.ProgressPercentage == 0)
{
try
{
string xmlData = e.UserState.ToString();
XmlDocument doc = new XmlDocument();
doc.LoadXml(xmlData);
XmlNode root = doc.FirstChild;
string messageType = root.ChildNodes[0].InnerText;
string messageText = root.ChildNodes[1].InnerText;
MessageRead(messageType, messageText);
}
catch (Exception ex)
{
string er = ex.Message;
MessageBox.Show(ex.Message);
}
}
else
{
if (e.ProgressPercentage == 100)
{
tcpThread.CancelAsync();
Thread.Sleep(200);
}
}
}
}
}
|
|
|
|
|
I am sending mails using an SMTPClient object and later I recover the results of the delivery by the statusCode of the instance of the SmtpException using the values of the SmtpStatusCode enumeration, but needing to generate exceptions all the system go really slow, do anybody know other way of recover the results of the delivery faster.
Best Regards
|
|
|
|
|
Hi, I want to let the user to insert a string that will create a function.
I know how to create a class or method at runtime.
I have a delegate and I want the function that the user been created will be stored in the delegate event that i use.
How can I do it?
Specification
The user can select the sorted function that he want's(Sort of some system class).
He gets a list with this functions for example:
1. Area
2. Length
3. Custom
If the user choose Area/length then the list of item that I have (very complex system) will be sorted by Area/Length but if the user choose 'Custom' then I want to show him a new Textbox and then he can write 'Area*Length +COS(Length)'.
This is my delegate:
delegate double GetGrade(SystemD SD);
GetGrade MyGrade;
1. Area:
MyGrade = new GetGrade(AreaGrade);
public double AreaGrade(SystemD SD)
{
return SD.Area;
}
2. Length:
MyGrade = new GetGrade(LengthGrade);
public double LengthGrade(SystemD SD)
{
return SD.Length;
}
3. Custom:
MyGrade = new GetGrade(CustomGrade);
public double CustomGrade(SystemD SD)
{
string str= CustomTextBox.Text;
double Grade= CompileAndGetDoubleNumber(str,SD);
return Grade;
}
I want to get the string from the user and create at runtime a function that can be overload to this event but I need this function before to compilation because then I can not choose the function for the event because the function does not exists.
What can I do to resolve this problem?
|
|
|
|
|
Perhaps Action[^] or Func[^] is what you need
only two letters away from being an asset
|
|
|
|
|
Hi Experts,
I have developed a winApp in C# 2.0. I have created Setup of the application that creates required registry keys into the registry. I want these keys should not be deleted when application is uninstalled. I have set DeleteOnUninstall Property to false in the setup project. Still if application is uninstalled the keys are getting deleted.
I dont know how to overcome these problem
Please help me out!!!!!!!!!!111
Thanks And Regards,
Paramhans Dubey
|
|
|
|
|
Did you read this on MSDN [^]?
If a registry key has values, the key will be removed when all values are removed regardless of the DeleteAtUninstall property setting.
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Hi Manas,
Thanks for your reply. I tried the link given by you but unable to connect to MSDN site. Anyways Can you guide me further? Can you please tell me how can I avoid these keys beeing deleted? Actually I want to keep track of the application installation on tha machine, like how many times this application has been installed to the machine, etc. Its part of licensing of the application.
Please help me
Thakns And Regards.
Paramhans Dubey.
|
|
|
|
|