OWIN OAuth server implementation with access_token in response header instead of URL hash fragment
Installation of 32 Bit Services and Applications on 64 Bit Operating Systems
Greetings.
I have several Windows services/applications that were written in Visual Studio.
There are hardcoded references to registry entries that the services/applications use to get database connections, queue locations, et cetera.
Here's an example of an existing variable from our code that gets a registry value that the app uses to get a root reference for some setting values:
private const string REG_KEY_SERVICE = @"Software\Company\App\AppName";
So, that being said, when our apps/services were installed on a 32 bit OS, there was no problem, however when the same apps/services are installed on a 64 bit OS, the registry settings are set here:
Software\Wow6432Node\Company\App\AppName
Since these settings are not in our configuration logic, we'd need to do a code change to something like this:
private const string REG_KEY_SERVICE = @"Software\Wow6432Node\Company\App\AppName";
This is not something that we want to do since it involves a version change and all of the change control processes that goes along with that.
To get around having to make a version change, on our dev environment, we are copying the registry entries from:
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432\Company\App\AppName
TO
HKEY_LOCAL_MACHINE\SOFTWARE\Company\App\AppName
My question: Is there a risk with this workaround and is this advisable?
Thanks.
doug
.NET Error Closing serial port BaseStream error is only available when the port is open
I'm using the .NET System.IO.Ports.SerialPort using the BaseStream as suggested in this post If you must use .NET System.IO.Ports.SerialPort
But when I try to close the port or the baseStream, an System.InvalidOperationException is raised saying "The BaseStream is only available when the port is open"
This is my code:
private void ActionStarted() { //ajusta el puerto setupSerial(); serial.Open(); //conecta al plc byte[] buffer = new byte[15]; Action kickoffRead = null; if (serial.IsOpen) //si esta abierto el puerto hace todo esto { kickoffRead = delegate() { serial.BaseStream.BeginRead(buffer, 0, buffer.Length, delegate(IAsyncResult ar) { try { int actualLength = serial.BaseStream.EndRead(ar); byte[] received = new byte[actualLength]; Buffer.BlockCopy(buffer, 0, received, 0, actualLength); raiseAppSerialDataEvent(received); } catch { } kickoffRead(); }, null); }; kickoffRead(); } }
and the error occurrs when I try to close the window / port / basestream here,
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { serial.BaseStream.Flush(); serial.BaseStream.Close(); serial.Close(); }
I read somewhere that the serial port should be close on a different thread but I can't find that, so any thoughts??
Thanks!!
how to parse reader comments in new source comment sections
I enjoy reading through the comment sections to articles in various news sources. However, the good comments are often hidden in the over abundance of spam and mind-numbing commentary. I would like to write an application that will selectively extract certain comments that I feel will most likely offer informative content (i.e. to reduce the time and my effort to find comments worth reading). For example, mind-numbing comments which I wish to ignore general consist of single sentences and it is not unusual for a comment section to have hundreds if not thousands of them. Conversely, many informative comments are much longer in length (e.g. two or more paragraphs).
I am proficient in developing desk top applications in a rich client environment but have only minimal experience working with web-related applications. As such, I am looking for suggestions on how I should approach this small project and work through it.
1) Is anyone aware of existing projects or sample source code which parses the contents of web pages using .NET?
2) It is possible to view the source of a browser web page. For example, in IE10 I from the main menu [View][Source]. The source includes the text of the article but none of the comments. That is, the actual comments are not included in the rendered HTML (e.g. view the source for http://www.cbc.ca/news/business/target-s-launch-into-canada-a-multifaceted-failure-1.2901789). So how can I obtain the comments so that I can then filter the ones I wish to review and ignore all the others.
If I should be posting this request in another forum then please let me know.
ThanX
Ian
SCCM2012R2 - Read timing settings of the deployment scheduler
Dear all,
our customer runs SCCM2012R2 to deploy update packages over night (. They use the scheduler to deploy the updates over night outside of business hours.
This customer wants us to write a small.net application that reads this scheduled timing from the SCCM settings and writes that into a protocol file for another system there are using. Every time when they enter a new scheduled timing or change the current on our app should be triggered to sync the protocol file.
I know that I ask for an extremely deep SCCM know-how, but I hope there are few gurus out there who can help me – or point me to a place / example / source where to start.
many thanks!
Retry method for generating unique code
In an app, a user can initiate the generation a six-digit alphanumeric code (actually done via Web API). The code needs to be checked against a remote database to ensure it is unique. Other than for diagnostics or logging, the DB table is only used by the Web API and an Azure web job that cleans out expired codes.
In my tests, collisions occurred on average only one in ~24K times with a high of 85K and a low of 170. It is the latter that concerns me. Although the table is emptied of expired codes daily, at some point there will be a collision. Although unlikely, it could happen with very few records in the table.
It is worth noting that because of exterior requirement, the code is limited to six characters from AEFGHJKLPQRSTUWXYZ123456789.
A simplistic solution would be to keep running the generation/check until a unique code is created. In all likelihood, this would only mean 1-2 iterations. But there's no guarantee. And certainly it can't run unfettered.
The next step would be to put a limit - say 5 tries - through a simple loop. This may be enough of a solution. Despite concern that the user would be frustrated if it ultimately fails, if it does there's probably enough wrong with the overall system to ruin the user experience anyway.
I have good exponential backoff code so although this is not a network issue (also a concern), it may help to incorporate it into the retry scheme. In fact, that might be a nice catch-all solution. Given 5 increasing temporal delays in retrying, it would allow both enough chances for the logical code to exceed the chances of a collision and mitigate introducing more stress on network resources.
Any suggestions/observations would be appreciated.
FYI, this is the code used to generate codes:
/// <summary>
/// Generates a randomized alphanumeric code
/// </summary>
/// <param name="strLength">e.g. 6 chars</param>
/// <param name="charSet">e.g. AEFGHJKLPQRSTUWXYZ123456789</param>
/// <returns>string of the specified length</returns>
public static string GenerateCode(int strLength, string charSet)
{
var chars = charSet.ToCharArray();
var data = new byte[1];
var crypto = new RNGCryptoServiceProvider();
crypto.GetNonZeroBytes(data);
data = new byte[strLength];
crypto.GetNonZeroBytes(data);
var result = new StringBuilder(strLength);
foreach (var b in data)
{
result.Append(chars[b % (chars.Length)]);
}
return result.ToString();
}
How to get the asseblies related to various power shell cmdlets
Hello All ,
I am trying to call some power shell commands from C# using System.Management.Automation , For example I am trying to execute the Lync server cmdlet "get-csdialplan" , I can get references of Type PSObject but I know that this cmdlet returns Objects of type Microsoft.Rtc.Management.WritableConfig.Policy.Voice.LocationProfile , I need to access the returned object as they are of this return type rather than as PSObject . From where can I get the assemblies containing those returned types for Lync ?
Best Regards ,
Article ID: 2583681 .NET Framework 4.0 applications that use the System.Net.HttpWebRequest and related classes may experience slow responses when using Automatic Proxy Detection - is a fix available
We have migrated our .net 2.0 application to .net 4.0 framework. We make TCP,HTTP requests & web pages, SOAP calls from our WPF based application to the server. From our statistics collected though our client base, our 4.0 TCP request/responses are ~0.20 ms slower than 2.0 TCP calls and web requests are slower upto one sec. The above listed article -https://support.microsoft.com/kb/2583681
says that the System.net API in 4.0 are slower than 2.0 API while using Automatic proxy detection. Is there any hot fix available for this issue? Has this been fixed in .net 4.5 or the same issue exists in .net 4.5 too?
Will Microsoft support DirectX in .Net Framework?
I know about Managed DirectX, XNA that are no longer supported.
I know about 3d party libraries.
I am talking about official support.
Retrieving the COM class factory for component with CLSID {} failed due to the following error: 800703fa.
Hi,
One of my windows service is using a third party component. I have an Interop.myobject.dll generated from the .tlb file from the third party client. It is working fine in my development machine, but when deploy it to 32-bit server I am getting this error:
Retrieving the COM class factory for component with CLSID {} failed due to the following error: 800703fa.
I checked the registry to see the Class ID. It exists and points to path of the .exe. This is making me frustated me for few days now.
Please help.
ZipPackage - Size limits? When does compression take place?
I am rewriting some backup/restore code in one of our products that used to use Compound Documents. I am evaluating using ZipPackage in the new code as it's built into the framework. Two questions I have that I can't seem to find answers to.
1. Are there any size limits in dealing with ZipPackage? We have clients that have backups that are 4GB or more. Huge backups. Are there any explicit limits to dealing with data in the ZipPackage classes?
2. When exactly does compression take place? For example let's say I create 3 PackageParts, do they get compressed on the fly somehow? Are all three compressed when I call Flush()? Or on Close()? I just can't find any specifics as to when the compression takes place.
DLL corrupted after sending it by mail
I am writing external libriaries to account program.
I am sending them by mail to customer, every time I send them by mail customer gets corrupted DLL. If I copy DLL to flash drive and then copy DLL to customer computer everything is fine, and DLL works. Can anyone explain me why DLL gets corrupted by sending them by mial? DropBox gives the same result, DLL gets corrupted.
Hang on AppDomain.Unload() only on Windows 8.x (language OS i.e. german, japanese, etc)
We have unmanaged application which loads unmanaged DLLs whereas one of the DLL also loads a Mediator DLL which supports and loads managed code(C#).
After launch of application, Mediator DLL initializes managed code and further managed code creates a AppDomain, loads plugins and attempts to unload the AppDomain.
The statement AppDomain.UnLoad() hangs on Language Windows 8.x OS (tested on German and Japanese).
Below is the sample code
RemoteClassLoader instanceloader = null;
AppDomain LoaderAppDomain = null;
LoaderAppDomain = AppDomain.CreateDomain("Loader Domain");
instanceloader = (RemoteClassLoader)LoaderAppDomain.CreateInstanceAndUnwrap(this.GetType().Assembly.FullName, typeof(RemoteClassLoader).ToString());
if (LoaderAppDomain != null)
{
AppDomain.Unload(LoaderAppDomain);
}
Above code has been working since Windows XP in english as well as language OS but started to hang with Windows 8.x language OS (difference here is, we have moved to .net framework 4.5.1, no issues with 3.5 framework).
On Analyzing the dump using WinDBG, there is a possibility of OS thread(whntnotifychangedirectoryfile)
Following are the details of dump.
0:000> !analyze -v
*******************************************************************************
*
*
* Exception Analysis
*
*
*
*******************************************************************************
*** ERROR: Symbol file could not be found. Defaulted to export symbols for <exe name>.exe -
*** ERROR: Symbol file could not be found. Defaulted to export symbols for DOMXT.dll -
*** ERROR: Symbol file could not be found. Defaulted to export symbols for omniORB413_vc10_rt.dll -
GetUrlPageData2 (WinHttp) failed: 12029.
FAULTING_IP:
+ca03d1a6b0
00000000`00000000 ?? ???
EXCEPTION_RECORD: ffffffffffffffff -- (.exr 0xffffffffffffffff)
ExceptionAddress: 0000000000000000
ExceptionCode: 80000007 (Wake debugger)
ExceptionFlags: 00000000
NumberParameters: 0
CONTEXT: 0000000000000000 -- (.cxr 0x0;r)
rax=00009bcdc4f389b2 rbx=0000000000000001 rcx=0000000000001004
rdx=0000000000000001 rsi=0000000000000002 rdi=0000000000000002
rip=0000000077c82772 rsp=000000000008ee08 rbp=000000000018d91c
r8=0000000000000004 r9=0000000000000006 r10=0000000077bfb980
r11=000000000018d978 r12=00000000fffdc000 r13=000000000008fdb0
r14=000000000018d79c r15=0000000077c81f30
iopl=0 nv up ei pl nz na po nc
cs=0033 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00200206
wow64cpu!CpupSyscallStub+0x2:
00000000`77c82772 c3 ret
BUGCHECK_STR: 80000007
DEFAULT_BUCKET_ID: APPLICATION_HANG
PROCESS_NAME: <exe name>.exe
ERROR_CODE: (NTSTATUS) 0x80000007 - {Kerneldebugger aktiviert} Der Systemdebugger wurde von einem Interrupt aktiviert.
EXCEPTION_CODE: (HRESULT) 0x80000007 (2147483655) - Vorgang abgebrochen
NTGLOBALFLAG: 0
APPLICATION_VERIFIER_FLAGS: 0
APP: quarkxpress.exe
ANALYSIS_VERSION: 6.3.9600.17298 (debuggers(dbg).141024-1500) amd64fre
MANAGED_STACK: !dumpstack -EE
No export dumpstack found
DERIVED_WAIT_CHAIN:
Dl Eid Cid WaitType
-- --- ------- --------------------------
0 e20.790 Speculated (Triage) -->
1 e20.458 Idle Thread
WAIT_CHAIN_COMMAND: ~0s;k;;~1s;k;;
BLOCKING_THREAD: 0000000000000458
PRIMARY_PROBLEM_CLASS: APPLICATION_HANG
LAST_CONTROL_TRANSFER: from 0000000077bd73ff to 00007ffeb2eb757a
FAULTING_THREAD: 0000000000000001
STACK_TEXT:
00000000`0346e808 00000000`77bd73ff : 00000005`00000001 00000000`00000000 00000000`0346f0d0 00000000`0346e7b0 : ntdll!NtNotifyChangeDirectoryFile+0xa
00000000`0346e810 00000000`77bcbb64 : 00000000`0512bef4 00000000`fffdb000 00000000`77bd738c 00000000`fffd9000 : wow64!whNtNotifyChangeDirectoryFile+0x73
00000000`0346e880 00000000`77c821e5 : 00000023`77ccc14c 00000000`00000023 00000000`00000000 00000000`0512fff0 : wow64!Wow64SystemServiceEx+0xd4
00000000`0346f130 00000000`77bd323a : 00000000`00000000 00000000`77c81503 00000000`00000000 00000000`77bd3420 : wow64cpu!ServiceNoTurbo+0xb
00000000`0346f1e0 00000000`77bd317e : 00000000`00000000 00000000`00000000 00000000`0346fd30 00000000`0346f830 : wow64!RunCpuSimulation+0xa
00000000`0346f230 00007ffe`b2e47004 : 00000000`00000000 00000000`00000000 00000000`fffdf000 00000000`00000000 : wow64!Wow64LdrpInitialize+0x172
00000000`0346f770 00007ffe`b2e46eda : 00000000`0346f830 00000000`00000000 00000000`00000000 00000000`fffdf000 : ntdll!_LdrpInitialize+0xd8
00000000`0346f7e0 00000000`00000000 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : ntdll!LdrInitializeThunk+0xe
FOLLOWUP_IP:
wow64!whNtNotifyChangeDirectoryFile+73
00000000`77bd73ff 4885ff test rdi,rdi
SYMBOL_STACK_INDEX: 1
SYMBOL_NAME: wow64!whNtNotifyChangeDirectoryFile+73
FOLLOWUP_NAME: MachineOwner
MODULE_NAME: wow64
IMAGE_NAME: wow64.dll
DEBUG_FLR_IMAGE_TIMESTAMP: 5215f8c5
STACK_COMMAND: ~1s ; kb
BUCKET_ID: 80000007_wow64!whNtNotifyChangeDirectoryFile+73
FAILURE_BUCKET_ID: APPLICATION_HANG_80000007_wow64.dll!whNtNotifyChangeDirectoryFile
ANALYSIS_SOURCE: UM
FAILURE_ID_HASH_STRING: um:application_hang_80000007_wow64.dll!whntnotifychangedirectoryfile
FAILURE_ID_HASH: {02742019-f52a-83db-ef20-8723a2174738}
0:000> ~
. 0 Id: e20.790 Suspend: 1 Teb: 00000000`fffdc000 Unfrozen
1 Id: e20.458 Suspend: 1 Teb: 00000000`fffd9000 Unfrozen
2 Id: e20.a18 Suspend: 1 Teb: 00000000`fffd6000 Unfrozen
3 Id: e20.db4 Suspend: 1 Teb: 00000000`ffea4000 Unfrozen
4 Id: e20.c38 Suspend: 1 Teb: 00000000`ffea1000 Unfrozen
5 Id: e20.ab0 Suspend: 1 Teb: 00000000`ffe9e000 Unfrozen
6 Id: e20.3f4 Suspend: 1 Teb: 00000000`ffe95000 Unfrozen
7 Id: e20.ec0 Suspend: 1 Teb: 00000000`ffe92000 Unfrozen
8 Id: e20.a54 Suspend: 1 Teb: 00000000`ffe8f000 Unfrozen
9 Id: e20.9bc Suspend: 1 Teb: 00000000`ffe8c000 Unfrozen
10 Id: e20.f4c Suspend: 1 Teb: 00000000`ffe89000 Unfrozen
11 Id: e20.fd0 Suspend: 1 Teb: 00000000`ffe86000 Unfrozen
12 Id: e20.5bc Suspend: 1 Teb: 00000000`ffe7d000 Unfrozen
13 Id: e20.f1c Suspend: 1 Teb: 00000000`ffe7a000 Unfrozen
14 Id: e20.bf0 Suspend: 1 Teb: 00000000`ffe77000 Unfrozen
15 Id: e20.d3c Suspend: 1 Teb: 00000000`ffe74000 Unfrozen
16 Id: e20.ff0 Suspend: 1 Teb: 00000000`ffead000 Unfrozen
17 Id: e20.930 Suspend: 1 Teb: 00000000`ffeaa000 Unfrozen
Followup: MachineOwner
Did anybody face similar kind of issue ? I will appreciate inputs to analyze this issue.
Previously posted on
https://social.technet.microsoft.com/Forums/windows/en-US/d051e8d2-7ccc-473a-b1ed-d2621203feff/hang-on-appdomainunload-only-on-windows-8x-language-os-ie-german-japanese-etc?forum=w8itproappcompat
Could not write log to text log file for windows service in win2012 server.
Hi all,
I cannot write log data for my windows service in to a text log file. I can see only starting and stopping of the service. Can anybody help me on how to write to log file. The service was migrated from win2003 server to win2012 server. It is working fine
in win2003 server but failing in win2012 server. Please help me on this.
Many thanks in advance.
sammy
How to do URL rewritting & URL redirecting in ASP .Net 3.5 framework
How to do URL rewriting in ASP .Net 3.5 framework.
My Current URL is http://www.abc.com/Products.aspx?mid=192 and
I want URL rewrite in below pattern
http://www.abc.com/products/product-category/productname/192
Google has cached current URL, so how can I redirect it to new rewrited URL.
Please advice.
Thanks in advance.
XML -> Xpath
Hi All,
I have xml in below format
<Parent>
<ABC:ChildS>
<ABC:Child name="UDF01" type="SELECTION" code="1">Value1</ABC:Child>
<ABC:Child name="UDF02" type="SELECTION" code="Test2">Value2</ABC:Child>
</ABC:ChildS>
</Parent>
Here i need to fetch the Value1 or Value2 based on setting. I need the Xpath value to fetch Value1 and Value2
Creating a class library in VS2013 that can be referenced by a VB6 application and newer applications
EventRegister 1.0.26 feedback: localization, versioning, OutputType
I'm not sure what is the proper feedback channel for the Microsoft.Diagnostics.Tracing.EventRegister 1.0.26, Microsoft.Diagnostics.Tracing.EventSource 1.0.26, and Microsoft.Diagnostics.Tracing.EventSource.Redist 1.0.26 NuGet packages, so I'll just post these here.
We've got a service that uses those packages for writing events to Windows Event Log. It thus needs a provider manifest with channels and such. The messages and maps are localized to a few languages.
- When the project is being built on .NET Framework 4.0 (not 4.5.1), eventRegister.exe does not find the satellite assemblies that contain the localized strings, so it silently omits the corresponding <resources> elements from the manifest. The -ReferencePath option of eventRegister.exe does not solve the problem because it works by adding a handler for the AppDomain.ReflectionOnlyAssemblyResolve event and ResourceManager does not use reflection-only loads. Workaround: Add a custom target that copies the satellite assemblies to subdirectories of the directory that contains eventRegister.exe.
- The CreateEtwManifestsAndRegDllsCore target in Microsoft.Diagnostics.Tracing.EventRegister.targets has Inputs="$(AssmName)" and does not declare any dependency on satellite assemblies. If I edit only *.resx files and build the project, then Visual Studio compiles only the satellite assemblies and not the main assembly, and it skips the CreateEtwManifestsAndRegDllsCore target because the output files are already newer than the main assembly. The *.dll and *.man files generated by this target will then not contain the updated translations from the *.resx files. Workaround: Before building the project, touch some source file that is compiled to the main assembly.
- When I add parameters to an event that was already defined in a previous version of the software, I'd like to keep the original definition as well, so that Event Viewer can still format the events logged by the previous version. To do that, I'd define another method with the same eventId but a higher EventAttribute.Version, and perhaps rename the original method so that the localization resources don't clash. However, if I try that, then eventRegister.exe fails and says the event ID is already in use.
- If I define multiple events with the same Task and the same Opcode, then eventRegister.exe fails ("Event a (with ID b) has the same task/opcode pair as event c (with ID d)"). Why this restriction?
- There seems to be no way to define task-specific opcodes, so all opcodes consume the same 8-bit space.
- There seems to be no way to specify an OutputType (e.g. win:Win32Error) for a parameter of an event.
- There is a good error message "a property insert in the event message is referencing a non-existent property" if I specify e.g. "{9}" in EventAttribute.Message and the method does not have that many parameters. However, if I make the same mistake in the resources to which EventSourceAttribute.LocalizationResources refer, then there is no warning. I think errors in the *.resx files are even more likely than in the *.cs file, because the list of parameters is not immediately visible.
- When an event has many parameters, it is difficult to verify that all the "{number}" placeholders refer to the correct parameters. Because they get converted to "%number" at build time anyway, it might make sense to allow "{parameterName}"
as well, both in EventAttribute.Message and in resource files.
Control.invoke() throws System.ArgumentException with Error message as 'Parameter is not valid'
Hi All,
While doing cross thread communication, i am getting System.ArgumentException with Error message as 'Parameter is not valid' when call is made on the control.invoke(delegate method, parama object[]).
I have checked the parameters, all parameters look good.
Please share your views on this.
Exception in NinjectWebCommon.cs file
Hi,
When I try to run the .NET MVC3 application I am getting the below exception. But the same application is working fine earlier.
Method not found: 'System.Web.Http.Services.DependencyResolver System.Web.Http.HttpConfiguration.get_ServiceResolver()'.
I am using the System.Web.Http version is 4.0 and System.Web.MVC version is 3.0.
Please help me to resolve this issue.
Thanks & Regards,
Ram Tummala.