Any advice is very much appreciated.
Any advice is very much appreciated.
We have encountered an issue while upgrading our product with .Net Framework 3.5 to latest version with .NET Framework 4.5.1. We came into a situation, where one application is using a logger assembly built with .NET framework 3.5, another application(built on 4.5.1) tries to uninstall same logger assembly which is being used by previous application, but it couldn’t proceed. As it keeps on searching the logger assembly in 4.0 GAC and takes significantly lot more time.
However above scenario works smoothly where older and newer products are built on .NET Framework 3.5 only.
Note: Assembly is getting uninstalled by windows installer not by GACUTIL utility.
using (var client = new HttpClient())
{
client.BaseAddress = new Uri(Url);
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml"));
using (var task = client.PostAsJsonAsync(Url, body))
{
if (task.Result.StatusCode != HttpStatusCode.OK)
throw new Exception(task.Result.ReasonPhrase);
}
}
Not Sure why we get the Only one usage of each socket address (protocol/network address/port) is normally permitted xx.xxx.xxx.xx:80 error
System.AggregateException: One or more errors occurred. ---> System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException:
Only one usage of each socket address (protocol/network address/port) is normally permitted xx.xx.xx.xx:80
at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context)
at System.Net.Http.HttpClientHandler.GetRequestStreamCallback(IAsyncResult ar)
--- End of inner exception stack trace ---
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
Hi,
in my web project, I've directed authenticated users with membership method.
but now I want do it manually. but I have roles yet. when I want redirect authenticated user to his profile app use "return URL". I read this topichttp://msdn.microsoft.com/en-us/library/ka5ffkce%28v=vs.110%29.aspx. but don't get my solution.
I thanks anyone that guide me! :)
Good luck!
Hi,
I am new to pos.net please can you help me with code which is used for any thermal printer conncted with my asp.net application. I want to print div tag contents to printer.
Thanks in advance.
What's the usage pattern of HttpResponseMessage.EnsureSuccessStatusCode()
?
It disposes of the Content of the message and throws HttpRequestException
,
but I fail to see how to programmatically handle it any differently than a generic Exception
.
For example, it doesn't include the HttpStatusCode
,
which would have been handy.
Is there any way of getting more info out of it? Could anyone show relevant usage pattern of bothEnsureSuccessStatusCode()
and
HttpRequestException?
I implemented Transaction Scope in my application. But i receive following errorThe operation is not valid for the state of the transaction. Here is my code
try{ using (System.Transactions.TransactionScope scope = new System.Transactions.TransactionScope()) { UpdateDataBase1(); UpdateDataBase2(); // this line throws error. scope.Complete(); } } catch(Exception ex) { throw ex;//Inner exception is null }
Both Databases are on same server(Server1)(MSDTC service is running).
My Application is on different server(server2).
I googled around and found two post with the same problem.
and
I found that there may be 2 main causes for my problem (1) MSDTC service and (2) Transacation Scope cannot handle to open connections.
But when i test the same scenario in local it works. The above 2 possible causes works very fine.I dont know what happens when i host them.
help me.
markand
In a COM+ application in production environment we get the following error:
System.Runtime.InteropServices.COMException (0x80080008): Object server is stopping when OLE service contacts it (Exception from HRESULT: 0x80080008 (CO_E_SERVER_STOPPING))
What is the cause of this problem and how can we solve it?
My scenario is as follows:
BizTalk TCP/IP adapter sends multiple request at a time.
Now I have to create a C# console application which will handle those requests.
For each simultaneous request,I have to create a new thread and that thread will remain in the app until it get a response from DB.
How it is possible ?
Prakash
IN ftp server directory having nearly 4000 files but i can list 510 files only,(implicit over TLS security) can any help me to list the full files from dir....
here is my code
// try
{
/* Create an FTP Request */
ftpRequest = (FtpWebRequest)FtpWebRequest.Create(host + "/" + directory);
/* Log in to the FTP Server with the User Name and Password Provided */
ftpRequest.Credentials = new NetworkCredential(user, pass);
/* When in doubt, use these options */
ftpRequest.UseBinary = true;
ftpRequest.UsePassive = true;
ftpRequest.KeepAlive = true;
ftpRequest.EnableSsl = true;
// X509Certificate x = new X509Certificate();
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
/* Specify the Type of FTP Request */
ftpRequest.Method = WebRequestMethods.Ftp.ListDirectory;
/* Establish Return Communication with the FTP Server */
ftpResponse = (FtpWebResponse)ftpRequest.GetResponse();
/* Establish Return Communication with the FTP Server */
ftpStream = ftpResponse.GetResponseStream();
/* Get the FTP Server's Response Stream */
StreamReader ftpReader = new StreamReader(ftpStream);
/* Store the Raw Response */
string directoryRaw = null;
/* Read Each Line of the Response and Append a Pipe to Each Line for Easy Parsing */
try { while (ftpReader.Peek() != -1) { directoryRaw += ftpReader.ReadLine() + "|"; } }
catch (Exception ex) { }
/* Resource Cleanup */
ftpReader.Close();
ftpStream.Close();
ftpResponse.Close();
ftpRequest = null;
/* Return the Directory Listing as a string Array by Parsing 'directoryRaw' with the Delimiter you Append (I use | in This Example) */
try { string[] directoryList = directoryRaw.Split("|".ToCharArray()); return directoryList; }
catch (Exception ex) { Console.WriteLine(ex.ToString()); }
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
//
Greetings,
I have a program running a FileSystemWatcher to watch for changes to a log file on a mapped drive (code below). This same program is running on three different production machines and two of them are working perfectly.
On the third machine every few seconds I receive a monitor error that contains the line;
'System.ComponentModel.Win32Exception (0x80004005): The specified server cannot perform the requested operation'.
This message is very ambiguous and general (at least to me). Have googled it but to no avail. The inner exception is blank so it's of no help.
Can anyone please shed some light on what this error means and perhaps why it would be occurring?
Thank you.
Dale Hoffman
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace FileSystemWatcherTest { class Program { static FileSystemWatcher _monitor; static void Main(string[] args) { StartWatcher(); Console.WriteLine(@"Press any key to exit."); Console.ReadKey(); } private static void StartWatcher() { try { _monitor = new FileSystemWatcher(); //_monitor.InternalBufferSize = 16384; _monitor.Path = @"L:\"; _monitor.IncludeSubdirectories = false; _monitor.Filter = "DPJobState*.txt"; _monitor.NotifyFilter = NotifyFilters.LastWrite; _monitor.Error += OnMonitorError; _monitor.Changed += new FileSystemEventHandler(OnMonitorChanged); _monitor.EnableRaisingEvents = true; } catch (Exception ex) { _monitor.Dispose(); using (StreamWriter swLog = new StreamWriter(@"c:\Tools\Log\AutoCreditingMonitorLog.txt", true)) swLog.WriteLine(DateTime.Now.ToString() + ex); System.Threading.Thread.Sleep(1000); StartWatcher(); } } private static void OnMonitorChanged(object sender, FileSystemEventArgs e) { _monitor.EnableRaisingEvents = false; using (StreamWriter swLog = new StreamWriter(@"c:\Tools\Log\AutoCreditingLog.txt", true)) swLog.WriteLine(DateTime.Now.ToString() + " Log file changed"); _monitor.EnableRaisingEvents = true; } private static void OnMonitorError(object source, ErrorEventArgs e) { _monitor.Dispose(); using (StreamWriter swLog = new StreamWriter(@"c:\Tools\Log\AutoCreditingErrorLog.txt", true)) swLog.WriteLine(DateTime.Now.ToString() + " Monitor error detected: " + e.GetException()); System.Threading.Thread.Sleep(1000); StartWatcher(); } } }
Dale Hoffman
First of all, I did search the entire forum but didn't find useful answer can solve my problem.
Here is my development tools and test environment information.
I am a graphics driver engineer and want to develop some tools for internal usage. .NET Framework give me the fastest way to create a decent GUI tool and this is reason why I choose it.
As I am working with graphics driver, I need update the keys under "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Video".
However, I run into the problem with the following line of code,
RegistryKey theVideoKey = Registry.LocalMachine.CreateSubKey(theKeyStr);
The error message is:
An unhandled exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll
Additional information: Access to the registry key 'HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Video\{????}\0000' is denied.
I tried everything I think could be useful found on the forum, such as "run as Adminitrator" but it doesn't work. Please help.
Hello everybody,
currently I'm working with the CultureInfo class. I want to use the DisplayName property to show the localized name of a language with respect to the choosen UI-language.
The MSDN-Library description says that this property provides the full localized name. But it seems that this doesn't work.
You can test it with the following simple code:
using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication3 { class Program { static void Main(string[] args) { List<int> lcids = new List<int>() { 1031,1033,1044}; foreach(int lcid in lcids) { CultureInfo culture = CultureInfo.GetCultureInfo(lcid); System.Threading.Thread.CurrentThread.CurrentCulture = culture; System.Threading.Thread.CurrentThread.CurrentUICulture = culture; Console.WriteLine(String.Format("set lang: {0} --- active lang: {1}", culture.Name, CultureInfo.CurrentCulture.Name)); foreach (int lcid1 in lcids) { CultureInfo culture1 = CultureInfo.GetCultureInfo(lcid1); Console.WriteLine(String.Format(" {0} \t {1} \t {2}", culture1.Name, culture1.DisplayName, culture1.NativeName)); } } Console.WriteLine("Press any key to close..."); Console.ReadKey(); } } }
The corresponding output is the following:
set lang: de-DE --- active lang: de-DE de-DE Deutsch (Deutschland) Deutsch (Deutschland) en-US Englisch (USA) English (United States) nb-NO Norwegisch, Bokmål (Norwegen) norsk, bokmål (Norge) set lang: en-US --- active lang: en-US de-DE Deutsch (Deutschland) Deutsch (Deutschland) en-US Englisch (USA) English (United States) nb-NO Norwegisch, Bokmål (Norwegen) norsk, bokmål (Norge) set lang: nb-NO --- active lang: nb-NO de-DE Deutsch (Deutschland) Deutsch (Deutschland) en-US Englisch (USA) English (United States) nb-NO Norwegisch, Bokmål (Norwegen) norsk, bokmål (Norge) Press any key to close...
Is this realy the expected behaviour?
Regards
Volker
I'm a bit puzzled and could do with some help. I have the following code for calling a webservice using the BCL.Async - UploadStringTaskAsync , the code below works fine when its in the xaml.cs class but when I move the code to a PhoneLibrary. it hangs on UploadStringTaskAsyncline and never timeout or returns anything. Any thoughts what going wrong.
xaml.cs
var http = new WebClient();
string postdata = "cmd=GWRLogin&data=%3cgip%3e%3cversion%3e1%3c%2fversion%3e%3cemail%3e???%40???????%3c%2femail%3e%3cpassword%3e3ec66b1?????156869af23318771f44aeb7f97780a88aa0e135c3f84%3c%2fpassword%3e%3c%2fgip%3e";
http.Encoding = System.Text.Encoding.GetEncoding("ISO-8859-1");
http.Headers[HttpRequestHeader.KeepAlive] = "true";
http.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
http.Headers[HttpRequestHeader.ContentLength] = postdata.Length.ToString();
var Token = await http.UploadStringTaskAsync("https://eon.?????.eu/???/???.php", "POST", postdata);
Textblock.Text = Token;
Dll and call
private void Button_Click(object sender, RoutedEventArgs e)
{
Greenwave gw = new Greenwave();
ResultBlock.Text = gw.Login().Result;
}
public class Greenwave
{
public async Task<string> Login()
{
var http = new WebClient();
string postdata = "cmd=GWRLogin&data=%3cgip%3e%3cversion%3e1%3c%2fversion%3e%3cemail%3e???%40???????%3c%2femail%3e%3cpassword%3e3ec66b1?????156869af23318771f44aeb7f97780a88aa0e135c3f84%3c%2fpassword%3e%3c%2fgip%3e";
http.Encoding = System.Text.Encoding.GetEncoding("ISO-8859-1");
http.Headers[HttpRequestHeader.KeepAlive] = "true";
http.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
http.Headers[HttpRequestHeader.ContentLength] = postdata.Length.ToString();
return await http.UploadStringTaskAsync("https://eon.?????.eu/???/???.php", "POST", postdata);
}
}
Regards
Kevin
Hi, while running our tests on our TFS build server we always have a warning in the "Other Errors and Warnings":
System.AppDomainUnloadedException: Attempted to access an unloaded AppDomain. This can happen if the test(s) started a thread but did not stop it. Make sure that all the threads started by the test(s) are stopped before completion.
I narrowed it down to some tests of a class using PrincipalContext. Then I was able to reproduce the problem with this minimal test:
<TestMethod()>
Public Sub PrincipalContext_DomainOnly_AppDomainUnloadedException()
Using ctx = New PrincipalContext(ContextType.Domain)
End Using
End Sub
When run through the built-in VS test runner, I get in the Output / Tests window:
------ Run test started ------
System.AppDomainUnloadedException: Attempted to access an unloaded appdomain. This can happen if the test(s) started a thread but did not stop it. Make sure that all the threads started by the test(s) are stopped before completion.
Any idea how to solve this? Thanks!
I am trying to print current active MDI form using PrintForm from VB PowerPacks. Sample code:
mdiPrintForm.PrintAction = System.Drawing.Printing.PrintAction.PrintToPreview
mdiPrintForm.Print(Me.ActiveMdiChild, PrintForm.PrintOption.FullWindow)
Problem is that my Form is too wide to fit in the page. It got cut off. I don't see anything in PrintForm that I can use to shrink the form to fit the page. Any suggestions. Much appreciated.
In real application, When or in what cases we should go for Connected mode(Data Reader) and disconnected mode(Data Adaptor, Dataset) in ADO.net ?
Please share your thougts