|
This example exists within the examples of on your computer.
<frameworksdk>\Samples\Technologies\Remoting\Basic\RemotingHello
Take 15-30 minutes to look at it. It's worth it.
|
|
|
|
|
Hmmm...
Took a little while to make the stuff work. My system has 2 network connections. One for the cable set top box for broadband and one for my local network. Add in ZoneAlarm as the firewall and mix until thoroughly confused.
IIS on this machine is bound to the local network, BUT it is not resolved to LOCALHOST (i may need to switch network connections over). So I had to edit the .config files to use the actual IP address. The web client implementation wants me to log in as I am not authorized to view the page even though IIS is configured for anonymous acess and so refuses my administrator password
However, running the service using DirectHost service works when using the consoleclient. I have loads of questions but I will carry on playing for while...
Cheers
Steve
|
|
|
|
|
hey guys and girls,
im trying to get the ability to embed a hastable value of the password im going to encrypt a file with, in the file its self (but not embedding the password its self though just the hastable it generates). After encrypting it like above, i want the decryptor to beable to compare the incoming password to the hashtable on the encrypted file, if the 2 match, then continue, my problem is i need the incoming stream, to seek passed the hashtable and start there (SeekOrigin.Begin), so the original data is intact,the problem is when i use the FileStream.Seek = Seek(hashtablelength,SeekOrigin.Begin) when it gets to the actualy decryption part, it freezes and doesnt do anything, Ill include the code below, Am i just not doing it right ? If i was unable to make my question clear enough please let me know,
Jesse M
(i clipped the code so it will not be 100% correct, but the bulk of it is there)
///
///Decryption Method
///
<br />
FileStream fin = new FileStream(inName, FileMode.Open, FileAccess.Read);<br />
FileStream fout = new FileStream(outName, FileMode.OpenOrCreate, FileAccess.Write);<br />
fout.SetLength(0);<br />
byte[] bin = new byte[buffersize];
long rdlen = 0;
long totlen = fin.Length;
int len;
RC2CryptoServiceProvider RC2 = new RC2CryptoServiceProvider(); <br />
PasswordDeriveBytes db = new PasswordDeriveBytes(KeySecretString,SaltByte);<br />
byte[] f= db.GetBytes(RC2.LegalKeySizes[0].MaxSize /16);<br />
RC2.IV = f; <br />
RC2.Key =f;<br />
CryptoStream encStream = new CryptoStream(fout, RC2.CreateDecryptor(RC2.Key, RC2.IV), CryptoStreamMode.Write); <br />
Console.WriteLine("Encrypting...");<br />
while(rdlen < totlen)<br />
{<br />
len = fin.Read(bin, 0, buffersize);<br />
encStream.Write(bin, 0, len);<br />
rdlen = rdlen + len;<br />
PD.PerformStep();<br />
Console.WriteLine("{0} bytes processed", rdlen);<br />
} <br />
The Code Project Is Your Friend...
|
|
|
|
|
Code example :
ClassA oClassA = new ClassA();
Thread oWorker = new Thread(new ThreadStart(oClassA.read)); //How??, this is only partially done
My ClassA has a method "read(out ArrayList Something)" which expect a reference to ArrayList as input paratemer. How could I do so in C# with the code above?
Thank You
|
|
|
|
|
Anthony_Yio wrote:
read(out ArrayList Something)"
i guess the delegate ThreadStart encapsulates any methods without any parameters.
Cheers,
Venkatraman Kalyanam
Chennai - India
"Being Excellent is not a skill, it is an attitude"
|
|
|
|
|
Thank you but your help doesn't seem helping.
|
|
|
|
|
Anthony_Yio wrote:
your help doesn't seem helping
Ok. One solution could be use module level variable for storing the parameter and manipulate it from with in the function.
Cheers,
Venkatraman Kalyanam
Chennai - India
"Being Excellent is not a skill, it is an attitude"
|
|
|
|
|
Ok, thank you for this time although I had found some solutions in the web already.
I thought you were just one of those irresponsible people where they like to post and run. Apparently, I am glad you are not because you are trying
Some of the solutions I found was
Thread local storage
or
Save it into the object state.
|
|
|
|
|
Thanks, i forgot to point to this article.
Cheers,
Venkatraman Kalyanam
Chennai - India
"Being Excellent is not a skill, it is an attitude"
|
|
|
|
|
Why can't you pass the reference to ArrayList in the constructor for ClassA()?
Gaulles
|
|
|
|
|
Reason is that I will need to process the reference parameter in the contructor itself unless I would to store the refence to a pointer but it would make my program to be unsafe.
I guess this is not an old C++ style programming anymore.
|
|
|
|
|
You could also and is probably better than spawning a new thread is to use the BeginInvoke(string str, AsyncCallback asc, object stateobject). You then call the EndInvoke(IAsyncResult result) to retrieve the answer from the function. You pass a reference to the Arraylist in the stateobject and your AsyncCallback method handles and the parameter within it's function.
The good thing here is that you don't have to create a new thread, but rather the delagate function is executing on a thread from the thread pool - no creation is necessary.
I understand that this is probably hard to understand if you've never seen it before but you can look up BeginInvoke. .NET supports asynchronous method calls wonderfully with delagate.BeginInvoke.
|
|
|
|
|
Thank you for your suggestion. I will look into it.
Actually, I just want to make a simple thread call with parameter but it ends up in complexities. Gosh, sometimes I just hate new technologies.
|
|
|
|
|
Actually it is already simple. Take a look ...
public delegate int StringDelegate(string str);
.
.
.
private int GetLength(string str)
{
return str.Length;
}
.
.
.
StringDelegate d = new StringDelegate(GetLength);
IAsyncResult ar;
ar = d.BeginInvoke("Hello", null, null);
ar.AsyncWaitHandle.WaitOne(); // Wait for the function to finish
int length = d.EndInvoke(ar); // Voila, the result
// Note that you can also have a callback function defined in the
// second parameter. If defined, this function will be called once
// the delagate has completed. In addition, you can pass a state
// object to your GetLength method like so ...
// private int GetLength(string str, object state) ...
// You now have other information in addition to the passed "Hello"
// parameter.
// Clearly delagates are the way to go. They are simple and are
// extremely flexible. Also remember that the thread runs within the
// thread pool. No creation is required !
|
|
|
|
|
Hi,
I have some postings in a database and these postings are all noted in HTML-form because my initial idea was to show them from a web-application. Now I also want to show them through a windows application, the question is: how?
So I want to render HTML and show it in a .NET Windows Application. But I can't find a control to show the HTML. I know there is a control to show Richt Text Format, but that's still no HTML. I also know you can use the Internet Explorer ActiveX component, but I don't really want to, because that component can only show HTML from physical files and URL's, not directly from a String....
Does anybody know about the existence of a .NET-component that can show HTML directly from a string or do I really have to use the IE-component???
Structured programming vs. chaotic mind boggling
|
|
|
|
|
D.D. de Kerf wrote:
Does anybody know about the existence of a .NET-component that can show HTML directly from a string or do I really have to use the IE-component???
There is no UI Windows Forms components related to HTML rendering.
With enough spare time ahead, you may write a simple HTML renderer from scratch (and post it ).
D.D. de Kerf wrote:
I really have to use the IE-component
What's wrong with it? Drag&drop the web component into your Form, then Navigate the about:blank page, and then retrieve the mshtml (microsoft.mshtml.dll primary interop assembly) object model, get the IHTMLDocument2 interface, and create an HTML rendering from a string using the IHTMLDocument2.write(...) method call. This article[^] uses mshtml.
|
|
|
|
|
Well, I didn't ever know that I could use this write-function. It is also the first time I've ever got it working. Here are the steps:
1) Add Explorer to your toolbox (customize toolbox -> COM components -> Microsoft Web Browser) and add it to your form
2) Add a reference in your C# project to Microsoft.mshtml
3) use mshtml in your .cs-file like this:
using mshtml;
4) Browse to about:blank like this (ieBrowser is the browser-component):
object o = new object();<br />
ieBrowser.Navigate("about:blank", ref o, ref o, ref o, ref o);
5) Fill the HTML from a string like this:
IHTMLDocument2 doc;<br />
object oDoc = ieBrowser.Document;<br />
doc = (IHTMLDocument2)oDoc;<br />
<br />
doc.write("<HTML>This is bold and this is italic</HTML>");
That should do the trick.
Thanks for the tips!!!
Structured programming vs. chaotic mind boggling
|
|
|
|
|
Hi , we have a free but limited control that _might_ do what you want.
http://www.compona.com/WikiEngine/WikiPageViewer.ascx?ID=44[^]
it has its own rendering engine and can render with different font settings and images.
but as i said , it is limited , no tables , no stylesheets , no selections(!) etc.
basiclly the following tags are implemented
<a href=...
<font face=... size=... color=...(named colors only right now)
<br>
<hr>
<img src="file://... or src="1" (refering to an image in an attached imagelist)
<b>
<i>
<u>
it wordwraps and can also autosize to make the content fit.
//Roger - Compona
|
|
|
|
|
I am trying to authenticate and changing password for a windows domain user using ADSI and C#. When i try to connect to the server using LDAP provider i am getting COMException and message saying Server not opperational.
Below is my code
try
{
DirectoryEntry myDirectoryEntry;
myDirectoryEntry = new DirectoryEntry
("LDAP://domain or machine name","user id","pwd");
myDirectoryEntry.Invoke("setPassword","NewPassword");
myDirectoryEntry.CommitChanges();
}
catch(System.Runtime.InteropServices.COMException ex)
{
Console.WriteLine(ex.Message);
Console.Read();
}
where i am going wrong.
your pointers in this regard appreciated
Cheers,
Venkatraman Kalyanam
Chennai - India
"Being Excellent is not a skill, it is an attitude"
|
|
|
|
|
Hi,I have the seam problem but one gay told me that I should see "Profesional C#" book.You can find it in www.wrox.com.Youo can see my problem at "Active Directory - Users or whatever".
Have a nice day.
|
|
|
|
|
vg_sarev wrote:
Active Directory - Users or whatever".
I did see that post. But even those examples are giving the same *king exception "Server is not operational"
Cheers,
Venkatraman Kalyanam
Chennai - India
"Being Excellent is not a skill, it is an attitude"
|
|
|
|
|
In C# is there a way to implement Thread que which is equalant to CWinThread
so that I can post messages to the Thread queue and handle message parsing
inside the Thread and post back to Main Window?
|
|
|
|
|
Code below implement such thread
<br />
[DllImport("user32.dll", CharSet=CharSet.Auto)]<br />
public static extern IntPtr PostThreadMessage( uint idThread, int msg, int wParam, int lParam);<br />
[DllImport("kernel32.dll", ExactSpelling=true, CharSet=CharSet.Auto)]<br />
public static extern int GetCurrentThreadId();<br />
[DllImport("User32.dll", CharSet=CharSet.Auto)]<br />
public static extern bool PeekMessage(ref MSG msg, int hWnd, uint wFilterMin, uint wFilterMax, uint wFlag);<br />
[DllImport("User32.dll", CharSet=CharSet.Auto)]<br />
public static extern bool GetMessage(ref MSG msg, int hWnd, uint wFilterMin, uint wFilterMax);<br />
[DllImport("User32.dll", CharSet=CharSet.Auto)]<br />
public static extern bool TranslateMessage(ref MSG msg);<br />
[DllImport("User32.dll", CharSet=CharSet.Auto)]<br />
public static extern bool DispatchMessage(ref MSG msg);<br />
<br />
#region MSG<br />
[StructLayout(LayoutKind.Sequential)]<br />
public struct MSG <br />
{<br />
public IntPtr hwnd;<br />
public int message;<br />
public IntPtr wParam;<br />
public IntPtr lParam;<br />
public int time;<br />
public int pt_x;<br />
public int pt_y;<br />
}<br />
#endregion<br />
<br />
<br />
public void AsyncShow()<br />
{<br />
if( m_guiThread == null )<br />
{<br />
ThreadStart start = new ThreadStart( BackgroundGUIThread );<br />
m_guiThread = new Thread( start );<br />
m_guiThread.IsBackground = true;<br />
m_guiThread.Start();<br />
}<br />
}<br />
<br />
public void Finish()<br />
{<br />
try<br />
{<br />
lock(this)<br />
{<br />
if( m_idThread >= 0 )<br />
{<br />
WindowsAPI.PostThreadMessage( (uint)m_idThread, (int)Msg.WM_CLOSE, 0, 0 );<br />
}<br />
<br />
m_guiThread.Abort(); <br />
m_guiThread.Join();<br />
}<br />
}<br />
catch( Exception exc )<br />
{ <br />
Trace.WriteLine( exc.Message + "\r\n" + exc.StackTrace, "PrgDlg Exception" );<br />
}<br />
}<br />
private void BackgroundGUIThread()<br />
{<br />
Thread.CurrentThread.Name = "Background GUI MsgLoop Thread";<br />
<br />
try<br />
{<br />
lock( this )<br />
{<br />
m_idThread = WindowsAPI.GetCurrentThreadId();<br />
this.Show();<br />
}<br />
<br />
MSG msg = new MSG();<br />
<br />
while( WindowsAPI.GetMessage( ref msg, 0, 0, 0 ) )<br />
{<br />
WindowsAPI.TranslateMessage( ref msg );<br />
WindowsAPI.DispatchMessage( ref msg );<br />
<br />
if( msg.message == (int)Msg.WM_CLOSE )<br />
{<br />
Trace.WriteLine( "Close", "thread (2)" );<br />
break;<br />
}<br />
}<br />
}<br />
finally<br />
{<br />
Trace.WriteLine( "Quit thread" );<br />
}<br />
}<br />
Good Luck
Alex Kucherenko
|
|
|
|
|
Alex, Thanks a lot.
Can you give me sample code , how to Implement PostMessage and Retriveing Custom messages to this Threaded Window?
|
|
|
|
|
Did you ever get a response?
I need to port an application from C++ to C# that used CWinThread too
|
|
|
|
|