Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all 8156 articles
Browse latest View live

printing dialog box

$
0
0

i am using a dll called dgvprinter and I am trying to exception catch a printer error, I have done this but I would like to know if any one knows how the heck do I close the printing dialog box after an exception has been captured.


Win10 Using WiFiDirect (C#): API Support For Internet Connection Sharing (ICS "Full Mode" - Routing+NAT)

$
0
0

With Wlan's HostedNetwork deprecated, are the C++ Windows XP APIs for Internet Connection Sharing (e.g., INetSharingManager) still valid and recommended for new code? 

Are additional properties and methods (to be) exposed in WiFiDirectLegacySettings or (elsewhere) as a replacement? 

Is devolving to use of netsh the recommended best practise, point forward?


Microsoft Translator API - Bad request problem

$
0
0

Hi,

I've seen threads on this issue but my problem is particularly confusing. I have a free $2m character subscription, a valid client id and secret. When I run my code I get to call the API a few times successfully (the most I've seen is 75 consecutive successful calls). Then every other call returns a Bad request response: The remote server returned an error: (400) Bad Request.

I create the token once with my credentials and never create it again. I loop through a file, parse it, and submit every parsed string for translation by calling the API. It seems that I reach some sort of limit that I'm now aware of.

When looking at my account, it doesn't seem to be discounting the characters that I've translated already which would make me highly suspicious that I have the wrong credentials when creating the token. I quadruple-checked that and everything seems to be ok.

Any guidance on what I may be missing here would be much appreciated.

Thanks!

Paulo


Paulo de Oliveira

Remove Enterprise Logging Default Log parameters

$
0
0
 

Dear sir/miss

I created a shared configuration to set my enterprise library so that I can use it from different types of projects/applications within one Solution in the Visual Studio. I have created my own template but I have issues as the result log is still adding all its default configuration parameters into the logs which I do not require. How do I configure my config file to remove the unnecessary default default configuration parameters.

Thank you for any help you can provide me with.

I have added the code snippet below:

App.Config

<enterpriseLibrary.ConfigurationSource selectedSource="System Configuration Source" parentSource="Shared Config">
    <sources>
      <add name="System Configuration Source" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.SystemConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
      <add name="Shared Config" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
           filePath="D:\Users\muthukumaran\Documents\Visual Studio 2013\Projects\Polycom Crestron\Backend AppConfig\External.config" />
    </sources>
</enterpriseLibrary.ConfigurationSource>

External.Config

 <loggingConfiguration tracingEnabled="true" defaultCategory="General">
    <listeners>
      <add name="Web Service Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        fileName="C:\PolycomLogs\WCFWebService.log" formatter="Text Formatter"
        rollFileExistsBehavior="Increment" rollInterval="Midnight" rollSizeKB="5000"
        timeStampPattern="dd-MM-yyyy " maxArchivedFiles="30" />

      <add name="Windows Service Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        fileName="C:\PolycomLogs\WindowsService.log" formatter="Text Formatter"
        rollFileExistsBehavior="Increment" rollInterval="Midnight" rollSizeKB="5000"
        timeStampPattern="dd-MM-yyyy " maxArchivedFiles="30" />
   </listeners>
    <formatters>
         <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        template="Timestamp: {timestamp(local)}{newline}&#xA;Message: {message}{newline}&#xA;Category: {category}{newline}&#xA;Severity: {severity}{newline}&#xA;Machine: {localMachine}{newline}&#xA;App Domain: {localAppDomain}{newline}&#xA;Process Name: {localProcessName}" name="Text Formatter" />
    </formatters>
    <categorySources>
      <add switchValue="All" name="WebServiceLog">
        <listeners>
          <add name="Web Service Trace Listener" />
        </listeners>
      </add>
      <add switchValue="All" name="WindowsServiceLog">
        <listeners>
          <add name="Windows Service Trace Listener" />
        </listeners>
      </add>
    </categorySources>
    <specialSources>
      <allEvents switchValue="All" name="All Events" />
      <notProcessed switchValue="All" name="Unprocessed Category" />
      <errors switchValue="All" name="Logging Errors &amp; Warnings">
        <listeners>
          <add name="Web Service Trace Listener" />
          <add name="Windows Service Trace Listener" />
        </listeners>
      </errors>
    </specialSources>
  </loggingConfiguration>

Result Logs Sample

--------------------------------------------------------------------------------------------------------------------------------------------------
Timestamp: 8/15/2016 5:45:13 PM
Message: Timestamp: 8/15/2016 9:45:13 AM
Message: Room Schedules: 1
Category:
Priority: -1
EventId: 0
Severity: Information
Title: Information in Class name: ActivatePhoneAlertService.cs, Method name: SendAlertTimer
Machine: APPS
App Domain: Backend Windows Service.exe
ProcessId: 134196
Process Name: C:\inetpub\wwwroot\PolycomCrestronWindowsService\bin\Debug\Backend Windows Service.exe
Thread Name:
Win32 ThreadId:37256
Extended Properties:
Category: WindowsServiceLog
Severity: Information
Machine: APPS
App Domain: Backend Windows Service.exe
Process Name: C:\inetpub\wwwroot\PolycomCrestronWindowsService\bin\Debug\Backend Windows Service.exe
--------------------------------------------------------------------------------------------------------------------------------------------------

Referencing .NET Core Library from another project in same solution

$
0
0

I'm trying to refactor a set of PCL libraries into .NET Core. These libraries will be consumed either by other .NET core libraries and by traditional Windows .NET apps (WPF or console). Each solution hosting such a library has at least 2 xproj projects: 1 for the library itself, and another for its xUnit-based tests. The latter is a .NET core library too, following the directions in https://xunit.github.io/docs/getting-started-dotnet-core.html. To reference the target library in the test library I just add a reference to its project from within the same solution (this seems to work at least for .NET Core libraries; if I include .NET desktop projects in the same solution, I have to reference the compiled DLL in the subfolder corresponding to the correct target platform. Don't know if this is the recommended practice).

Now this works fine with a simple library, but it seems that as soon as I am dealing with a .NET Core library importing other such libraries (in the form of NuGet packages from a local NuGet feed) VS is no more able to compile, as if the reference were not present. The reference is there, and packages are restored without errors; yet, no type from the referenced library is available. I tried referencing the compiled DLL directly, but nothing changes, so I see no option for testing my library other than packing it into a NuGet package and importing it. Of course in a testing phase this is not desirable, as I'll change the target library often while testing. Am I missing something here? Could anyone suggest the correct way of referencing .NET Core libraries?

Example .NET library JSON project (for `MyFx.Text.Conversion`):

    ...
    "dependencies": {
      "MyFx.Text": "1.0.1",
      "MyFx.Tools": "1.0.1",
      "NETStandard.Library": "1.6.0"
    },

    "frameworks": {
      "netstandard1.6": {
        "imports": [ "dnxcore50" ]
      },
      "net462": {
           "frameworkAssemblies": {
             "System.Xml": "4.0.0.0",
             "System.Xml.Linq": "4.0.0.0"
          }
      } 
    },
    ...

Example .NET Core test library targeting the above, in the same solution:

    ...
    "testRunner": "xunit",
    "dependencies": {
      "NETStandard.Library": "1.6.0",
      "xunit": "2.2.0-beta2-build3300",
      "dotnet-test-xunit": "2.2.0-preview2-build1029",
      "System.Runtime": "4.1.0",
      "MyFx.Text.Conversion": "1.0.0-*"
    },
    "frameworks": {
      "netcoreapp1.0": {
        "dependencies": {
          "Microsoft.NETCore.App": {
            "type": "platform",
            "version": "1.0.0"
          }
        },
        "imports": [ "dnxcore50", "portable-net45+win8+wp8+wpa81" ]
      }
    },
    ...

Regular expression consisting of .* doesn't return all matches?

$
0
0

Hi everyone,

If a regular expression consists of several occurrences of .*, shouldn't the number of matches it returns equal the times that a text fits in it? Apparently not, but why? Let me clarify what I mean:

I have this simple regular expression: .*.*.*.*.*.*.*
When I test the text BUS the result is two matches: one on position 0 (length 3), and one on position 3 (length 0, however I ignore any match with a different length than the test text). But: the first* indicates that "any character" on the first position may occur 0 times, which should match the non-existent character before the B. The result should be a match on position 1. I would also expect a match on positions 2, 3 and 4, in which respectively the first two, three and four non-existent characters before B are matched by.*.*, .*.*.* and .*.*.*.*.

I am actually more interested in the regular expression I should use instead that comes up with the desired matches. BUS by the way, is only one of very many words that will be held against the expression; for each word the expression should return every position on which the word fits. I am aware that there are other ways to solve this - that even may seem quite simple - but these are definitely no option. Suggestions, anyone?

Thanks in advance,
Cooz


Are there any limitations of FileSystemWatcher monitoring a UNC path on NAS server?

$
0
0

Hi All,

Currently, I'm developing a tool for monitoring any changes of xml files that are residing on a UNC folder (e.g. \\SharedServer\Data). The shared folder is on NAS server and it is using CIFS. The NAS server exposed the shared folder under Windows NT 4.0 Server as Domain functional level. So every user can access the folder with domain account. Pls see below information of Domain and NAS information

  • Domain is hosted on Windows NT 4.0 Server. I know it had been out of support for long time.
  • NAS server is Hitachi NAS.

The tool (using FileSystemWatcher of .NET v3.5) is working properly on my development environment (Windows Server 2008 R2 and a shared folder is hosted on the server). Unfortunately, after deploying the tool to a company server, it has not worked with a shared folder on Hitachi NAS. I'm investigating and finding out the real root cause. There might be 2 root causes. First, the domain system does not support FileSystemWatcher of .NET v3.5. Second, Hitachi NAS does not support. I tried to search FileSystemWatcher's supported environment of  on MSDN, but there is no any information related to NAS server.

I would appreciate for any support from everyone.

Thanks,

Nam Tran

TypeDescriptor.AddProvider doesnt work for object instance

$
0
0
Hi 



I am trying to write a CustomTypeDescriptionProvider for a Model in my MVC application.



I have done the implementation as described here http://msdn.microsoft.com/en-us/magazine/cc163804[dot]aspx

the GetProperties method gets called when i register the CustomTypeDescriptor using 

 [TypeDescriptionProvider(typeof(TitleTypeDescriptionProvider))]
    public class CustomDataRecursive2 : CustomTypeDescripto



or 

TypeDescriptor.AddProvider(t, typeof(CustomData));

however my requirement is to have a type descriptor for each instance.

When i use the below method below it doesnt work...

 TypeDescriptor.AddProvider(new CustomData.TitleTypeDescriptionProvider(), vacancy.CustomData);



The TitleTypeDescriptionProvider.GetTypeDescriptor is never called.

Am I missing something ? 


Unable to create QR barcode - OPOS

$
0
0

I am trying to implement the QR and Datamatrix barcode, when i try calling the PrintBarCode method by setting the symbology to BarCodeSymbology.QRCode i get exception saying the parameter value is invalid. 

In the stack trace i am able to see an exception is thrown by the validateBarCodeSymbology

   at Microsoft.PointOfService.Internal.PosCommonInternal.ThrowPOSException(String Resource, ErrorCode code)
   at Microsoft.PointOfService.BaseServiceObjects.PosPrinterBase.ValidateBarCodeSymbology(BarCodeSymbology symbology)
   at Microsoft.PointOfService.BaseServiceObjects.PosPrinterBase.PrintBarCode(PrinterStation station, String data, BarCodeSymbology symbology, Int32 height, Int32 width, Int32 alignment, BarCodeTextPosition textPosition)

 I am not sure what i should try next, any pointer/help in resolving the issue is appreciated .


ss



Download zipfiles from server

$
0
0

Hi,

I am using .Net framwork 4.5 system.io.compression namespace to create zip file. I want to download the zip file without saving in any path. ionic zip has zip.save(response.outputstream) to download a file without saving in any path. like this is there any property to download the zip file using compression namespace.

My requirement is to create a zip file without saving in any desired path using system.io.compression and download that file.Please share the property or code to download zip file.

Thanks in advance.


prince rajan

Include Microsoft Document Explorer in My Project

$
0
0

Hi,

Where can I download the Microsoft Document Explorer from? and how to include it in my C# project to use as my Help Viewer?

Thanks,

Jassim

SAML token support in .Net Core

$
0
0
When will .Net Core support SAML 2.0 token authentication?

Active TCP connection gets falsely reported as being in state TIME_WAIT

$
0
0

I'm currently encountering a strange problem with some of our own C# applications running on Windows 7 (usually embedded but the problem is not limited to the embedded variant), where I'm responsible for hardware and operating system configuration.
These applications each listen on a TCP port, and communicate with a Linux machine. Connections are established once in the beginning when all applications start and then constantly used (sending some bytes back and forth at least every few seconds).

After a random time, Socket.send calls in one(and only one) random C# application start failing with no apparent reason. Number of sent bytes is returned 0 and error handling points out that the connection would be in state TIME_WAIT. I don't believe that because captured mirrored network traffic from the switch does not show any clue, neither side is closing the connection. I even see the data the send call reported as beeing not sent (i.e. 0 bytes sent) on the wire.

Then the application developer then added a log output reporting the connection state through iphlpapi's GetExtendedTcpTable befor each send call.
This also shows some strange symptoms. Some minutes before the error finally kicks in, the local address of the connection switches over to 127.0.0.1, which is strange, because the socket is only bound to the public IP, the connection is never reset, also the state is still MIB_TCP_STATE_ESTAB.
This also does not have any other noticeable effects, network traffic and application logs still show communication running back and forth smoothly.

After some minutes then suddenly the owner PID changes to 0 and the state becomes MIB_TCP_STATE_TIME_WAIT.
The send call then fails and reports 0 bytes sent as mentioned above.
As I see on the switch, the data is still sent and received however. The application also continues to receive and process data through this connection. There are no FIN or RST packets from any side so IMHO the state just cannot be right, and the GetExtendedTcpTable output must be wrong, but send still also reports error.

I had tried and switched out one of the computers with a different model to rule out influence of the network card type driver, firmware etc. to no avail.

Any suggestions how we even can try to find out how to fix this would be appreciated!

Allowable column names in DataGridView in C#

$
0
0

Hello,

Actually i was creating an application in C# winforms in which i was using datagridview control.

I would like to know that which are all characters allowable in column names of datagridview in C#.

Thanks and Regards,

Hari


click "Proposed As Answer by" if this post solves your problem or "Vote As Helpful" if a post has been useful to you Happy Programming! Hari

C# Client for making HTTP/2 REST calls

$
0
0

Is there a specific HTTP/2 Client library in .NET to be used to make REST API calls to an HTTP/2 server? Assume the server can be built on any platform and supports HTTP/2.

Iif it exists, is there a certain minimum .net framework version and and OS Version requirement to use such a client library?

All I could find was HttpTwo by Jonathan Dick(now works with Microsoft) and 

https://github.com/MSOpenTech/HTTP-SPEED-PLUS-MOBILITY

The first one is incomplete and the second one was last checked in 3 years ago. Both don't seem production ready.

I cant find any documentation or sample code for such a simple thing. Seems everyone is doing there own thing with Google implementing some gRPC etc.

Or is it already there and I just can find it?


UserPrincipal.ChangePassword stops working after windows updates 3177108 and 3167679.

$
0
0

I have a web application that for years has been using the ChangePassword method on the UserPrincipal class to facilitate end user password resets. (The namespace is System.DirectoryServices.AccountManagement.)

The web application is being hosted on a 2012R2 domain member server with 2 x 2012R2 DCs on the same LAN.

This call has now stopped working and returns the exception "The system cannot contact a domain controller to service the authentication request. Please try again later. (Exception from HRESULT: 0x800704F1)  "

If I remove windows updates 3177108 and 3167679 it starts working again. So I started digging deeper.

The KB articles for this update partially explain the issue, but it doesn’t quite fit with my scenario; they say:

“Currently, the ability to change the passwords of disabled or locked-out accounts is supported only by NTLM. It is not supported by the Kerberos protocol. This security update prevents the Negotiate process from falling back to NTLM for password change operations when Kerberos authentication fails. Therefore, you will no longer be able to change the password for disabled or locked-out accounts after you install this security update. It is not secure to change disabled or locked-out user account passwords by using NTLM. This is why the ability of Negotiate to fall back to NTLM is disabled by this security update.  “

The problem with the above statement is that we are NOT trying to change disabled or locked out accounts, it is failing for all accounts.

So my question is : Does the ChangePassword method use NTLM behind the scenes to do the change? If so, is there an alternative that will work in conjunction with the 2 above windows updates?

It is a long shot posting this here but any wisdom is appreciated!

Test code to reproduce the problem:

using System.DirectoryServices.AccountManagement;

string domainName = "xxxxxxxxx";
string samAccountName = "xxxxxx.xxxx";
string password = "xxxxxxxxxx!";
string newPassword = "yyyyyyyyyy!";
UserPrincipal up = null;
PrincipalContext pn = null;
//Get naming context
pn = new PrincipalContext(ContextType.Domain, domainName, samAccountName, password);

//find user
up = UserPrincipal.FindByIdentity(pn, samAccountName);
up.ChangePassword(password, newPassword);

Download zipfiles from server

$
0
0

Hi,

I am using .Net framwork 4.5 system.io.compression namespace to create zip file. I want to download the zip file without saving in any path. ionic zip has zip.save(response.outputstream) to download a file without saving in any path. like this is there any property to download the zip file using compression namespace.

My requirement is to create a zip file without saving in any desired path using system.io.compression and download that file.Please share the property or code to download zip file.

Thanks in advance.


prince rajan

What is a NullReferenceException, and how do I fix it?

$
0
0

Hello I am Facing serious issue with Null reference Expection , i have same executable Code  version in Different machine , then development environment  , i am not getting any issues in development environment but , in End users PC ( only in Few PC) i am getting this error .

May be Usage of Linq ( extension in  way like ...) 

I Have refereed this link but not really helpful.

http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it

Major question why its  showing expection in only few PC not every machice 

 More info:

I am using DataTable Collection and DataRows 

Linq on them!.

Usage of Merge and Clone etc..

Thanks 

Ranjith  Murthy 


Ranjith@Learner @Microsoft products

Open a UserControl's DLL

$
0
0

Hi,

I created a Class Library and added a UserControl into it called employee_report.

I now need to call the DLL file dynamically (not through VS Add Reference) and then display that userControl in my WinForm application.

How can I do this please?

Thanks,

Jassim

help me plsssss

$
0
0
help me plssssss
i need your help........
when i installed visual studio 2015 community, (after down load this file in the main page of microsoft) i press to run this file and it not working, show the window error " the specified service does not exist as an installed service"
waiting for your report!!! thanks
Viewing all 8156 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>