|
|
hi
i am having problem when i am trying to write something on remote location using .net thread.
e.g. i have a central location letsay MachineName|MachineIP/SharedDrive.
and i am creating a thread on click of a button which i need to write some information on that location.
i have also added a node <identity impersonate="true" username="Domain\User" password="*******"> in web.config of my application.
and i have also given credential in <machine.config>--<processmodel enable="true" username="SameInWeb.Config" password="SameInWeb.Config">
but it is giving the following exception:
The system detected a possible attempt to compromise security. Please ensure that you can contact the server that authenticated you.
below is my method which i am calling on a separate thread.
private void WriteSomeThingToRemoteLocation ()
{
FileStream fileStream = null;
BinaryFormatter binaryFormatter = null;
System.Object systemObject = null;
System.Object obj = new object();
lock ( obj )
{
string _contractLocaterKey = Guid.NewGuid().ToString().Replace( "-", "" );
string fullPath = @"\\MyMachineIP\SharedDrive" + "\\" + _contractLocaterKey + ".dat";
try
{
fileStream = new FileStream( fullPath, FileMode.CreateNew, FileAccess.Write );
binaryFormatter = new BinaryFormatter();
systemObject = new object();
systemObject = "Hello this is testing1";
binaryFormatter.Serialize( fileStream, systemObject );
systemObject = new object();
systemObject = "Hello this is testing2";
binaryFormatter.Serialize( fileStream, systemObject );
}
// catch(Exception ex)
// {
// avoided for getting noticed what happened;
// }
finally
{
if ( fileStream != null )
{
fileStream.Close();
fileStream = null;
}
binaryFormatter = null;
systemObject = null;
}
}
}
please help in this matter as i am stucking in the problem from more than 3 days.
this thing is happening OK :
1. if i call this method directly on another method.
2. if i call this method in a console application .
3. if i call this method on a thread in a console application.
any help would be highly appreciated.
thanks
vishal sharma
Thanks & Regards
Vishal Sharma
vishalsharma556@yahoo.co.in
|
|
|
|
|
I have a VB 6 code with me. The code is playing with excel. It generates worksheets and adds templates to them, sets cell values, etc. I want to rewrite the entire code into C#.Net. For that I have used Microsoft Excel 11.0 COM reference. (This is same in VB6). The problem is that I cannot find code in C#.Net equivalent to VB6 counterpart. Examples are given below:
oBook.Worksheets("General")
or this
oSheet.Rows(2).Copy oSheet.Rows(i)
There are many examples like this.
Either I don't know how to write this in .Net or there is no equivalent.
Does anybody know, where I can learn how to use Excel in .Net 2003 in good amount of depth so that I can convert any code in VB6 to .Net 2003?
Regards
Anil
|
|
|
|
|
hi anil
look at this example
http://www.codeproject.com/office/package.asp
regards
|
|
|
|
|
Joe,
Thanks! That was a nice article. That solved my Worksheet("abc") problem.
Regards,
Anil
|
|
|
|
|
In any web application in C# how we can view/edit/delete some data in the FormView control without using any databaseobject control like sqldatasource,objectdatasource .We want to connect the FormView control with sql databse by writing code in codebehind(like using DataSet).
Waiting for reply......
priyabrata
|
|
|
|
|
hey
i am also looking for the same solution that u r stuck wid ....
i want to hard code form behind in my code behind without using databaseobjects ....
i 'vl inform if i find a solution ... kindly share if u find d way to do it ...
thanx
deepayan
|
|
|
|
|
Simple question.
Is there a command to copy a directory in a different path without doing this manually on files and sub-directory contained there?
I've not found any copy command on System::IO::Directory ... it's strange!
Thank you
Russell
|
|
|
|
|
If you wanna move the directory, use Directory.Move
|
|
|
|
|
No, .... sorry...I want to copy it
Russell
|
|
|
|
|
Do you want to copy subfolders too?
|
|
|
|
|
yes...like MS-DOS command xcopy does.
Of course, I can use directly that command, ... but I'm trying to understand if there is an implemented function that does this copy that I still not know.
Thank you
Russell
|
|
|
|
|
As fas as I know there is not such built-in function but if you search codeproject for xcopy you will find what you need.
|
|
|
|
|
To my knowledge, I feel you will need to iterate and copy each file.
|
|
|
|
|
You have to write you own recursive procedure...
Regards,
Shy.
|
|
|
|
|
Hello,
I think you are looking fot this[^]
All the best,
Martin
|
|
|
|
|
Another idea for you is to do a simple hack - use the Process class and start a process using the xcopy command like you mentioned in some of your other posts.
I actually have done this in a build app I wrote.
I've also used the process class for doing FTP and LPR (using the built-in Windows commands, since there are no easy classes in the framework for this).
David
|
|
|
|
|
Hi
I have already wrote about my problem. I have a string that comes from console app
after it i convert it with this procedure
static private string EncodeMessageForConsoleOutput(string Message)
{
//gag
if (MemoLog == null)
return Message;
if (EncodingFrom.CodePage == EncodingTo.CodePage)
return Message;
Decoder decoder = Encoding.UTF8.GetDecoder();
byte[] bytes = Encoding.UTF8.GetBytes(Message);
char[] chars = new char[bytes.Length * 5];//*2
int bytesUsed, charsUsed;
bool completed;
decoder.Convert(bytes, 0, bytes.Length,
chars, 0, chars.Length, true,
out bytesUsed, out charsUsed, out completed);
string ResultString = new string(chars, 0, charsUsed);
return ResultString;
}
but it does not work
Could you help me
what's the problem with this code?
|
|
|
|
|
Hello all,
how to compare two times using DateTime object. I need to compare hours & minutes only based on this i am showing some message.
plz help me
regards
GV Ramana
|
|
|
|
|
For hours and minutes only, without dates and seconds:
DateTime first;
DateTime second;
if (first.Hour > second.Hour)
{
}
else
if (first.Hour == second.Hour)
if (first.Minute > second.Minute)
{
}
else
if (first.Minute == second.Minute)
{
}
else
{
}
else
{
}
|
|
|
|
|
Hello,
Look at System.TimeSpan class.
All the best,
Martin
|
|
|
|
|
TimeSpan is what you need.
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Yu can use the System.TimeSpan class. Quite handy, especially when used in conjunction with System.DateTime .
<br />
DateTime dt1 = DateTime.Parse("2007/06/14 13:24:00");<br />
DateTime dt2 = DateTime.Parse("2007/06/14 12:00:00");<br />
TimeSpan ts = dt1 - dt2;<br />
double elapsed = ts.TotalHours;<br />
This will give you the total number of hours elapsed from dt1 until dt2. If you are rather interested in the total number of minutes that elapsed you can use:
double elapse = ts.TotalMiutes;
or a host of others.
|
|
|
|
|
Hi,
if you want to ignore the other fields in a DateTime, you can not easily use the available
functions, nor TimeSpan.
I then suggest something like this:
public static int CompareHourMinuteOnly(DateTime dt1, DateTime dt2) {
int diff=dt1.Hour-dt2.Hour;
if (diff==0) diff=dt1.Minute-dt2.Minute;
return diff;
}
|
|
|
|
|
Ramana. G.V wrote: how to compare two times using DateTime object. I need to compare hours & minutes only based on this i am showing some message.
If DateTimeObject1.TimeOfDay = DatTimeObject2.TimeOfDay Then<br />
'do something<br />
End If
|
|
|
|