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

CheckSignature on some SAML responses fails.

$
0
0

Hi Team,

We have implemented SAML authentication and using .Net framework 4.6.2

CheckSignature is failing on some SAML responses, so far we have found one such case. CheckSignature passes for all other SAML responses.

1. SAML response is valid

2. Certificate is valid

3. SAML response text was not altered.

Found this article on the web --> https://github.com/dotnet/corefx/issues/19198

Here is the code which checks signature on SAML response.

 XmlNamespaceManager manager = new XmlNamespaceManager(xmlDoc.NameTable);
            manager.AddNamespace("ds", SignedXml.XmlDsigNamespaceUrl);
            manager.AddNamespace("saml", "urn:oasis:names:tc:SAML:2.0:assertion");
            manager.AddNamespace("samlp", "urn:oasis:names:tc:SAML:2.0:protocol");

            XmlNodeList nodeList = xmlDoc.SelectNodes("//ds:Signature", manager);

            SignedXml signedXml = new SignedXml(xmlDoc);

            if (nodeList?.Count != 1)
            {
                return false;
            }

            //Load signedXml from SAML Response 

            signedXml.LoadXml((XmlElement) nodeList[0]);

            // Load certificate from file store
            X509Certificate2 cert = (certificate from file store.)

            //Verifiy signature using the public key in the signature and key signing ceritificate.

            return (signedXml.CheckSignature() || signedXml.CheckSignature(cert, true));

Please let me know, if there I am missing anything here.

regards,

Prashant.


Access to remote folder

$
0
0

Hi,

I have an app which must read, change and save (update) files on remote PC.

I have a special user/password to access the remote computer.

Is there any way to loging to remote computer from inside the app, do the job and then log off.

App works fine if I logging to remote PC before starting nut I don't like this. I'd like to have evrething hidden from enduser.

 

Thanks

Oleg

How the task manager functions work

$
0
0

I'm new to C# programming...I'm trying to make a logic something like making 2 applications never die. If application(A) process is exited then the other application(B) will start that application(A) process again and vice versa. (Must keep running until the computer is shut down)

Currently, I made a way of finding app(A).exe process and if doesn't exists process starts and vice versa. But this fires up the CPU..

I've used the backgroundworker which takes up alot of CPU, and the timer which doesn't take up alot of CPU..But there should something better than timer

I'm wondering if there's something like using event handler but I just can't get to it..

Is there any good way to use less CPU and have this logic working?


Having thread loop in Windows Form application

$
0
0

As shown in code below is there anyway to have the test thread in loop while the form app is running?

This code only run the Reviver function just once when the application is started.

public partial class Calculator : Form
    {

        public Calculator()
        {
            

            InitializeComponent();
            Thread test = new Thread(Reviver);
            test.Start();

        }
            
        public void Reviver()
        {
            var processName = Process.GetProcessesByName("CalculatorUpdater2");

            if (processName.Length == 0)
            {
                processName = Process.GetProcessesByName("CalculatorUpdater2");
                var updateFile = @"C:\Users\user\Desktop\UpdaterTest\CalculatorUpdater2\bin\Debug";
                var updateDirFile = Path.Combine(updateFile, "CalculatorUpdater2.exe");
                Process.Start(updateDirFile);
                return;
            }
        }

    }

Microsoft.ReportViewer.WebForms An error occurred during local report processing

$
0
0

Hi All,

I use Microsoft.ReportViewer.WebForms to create pdf files from an rdlc file. All of this works fine. However, we notice that every week or two we start to get the following error: "An error occurred during local report processing". This continues until we restart our web app (in azure). If we do not restart the web app, the web app will eventually become non responsive. So, I assume there is a memory issue or something similar. But we do not know how to fix it. This happens on multiple servers. We have also tried cloud services in azure and it happens there too. So there is something with this library. We actually have diffferent web apps with different versions of the same library and the same problem exists. So maybe we are doing something wrong int he code. Here is our code, maybe someone can help. Thank You, David

            int CurrencyId = WJNCurrency.GetSystemCurrency(CompanyId).CurrencyId;

            ReportViewer reportViewer = new ReportViewer();

            reportViewer.Height = System.Web.UI.WebControls.Unit.Parse("100%");
            reportViewer.Width = System.Web.UI.WebControls.Unit.Parse("100%");

            reportViewer.LocalReport.DataSources.Clear();

            reportViewer.ProcessingMode = ProcessingMode.Local;

            var assembly = System.Reflection.Assembly.GetExecutingAssembly();

            WJNReservation rv = WJNReservation.Get(ReservationId);

            reportViewer.LocalReport.ReportEmbeddedResource = "MTier.Reports.BookingPDFByReservationId.rdlc";

            reportViewer.LocalReport.EnableExternalImages = true;

            reportViewer.LocalReport.DataSources.Add(new ReportDataSource("DataSet1",
                 WJNPDFBookingConfirmation.GetPassengersAndPassesByReservationId(ReservationId).Tables[0]));

            DataTable TotalPriceDataTable = new DataTable();
            TotalPriceDataTable.Clear();
            TotalPriceDataTable.Columns.Add("TotalCardServiceFee");
            TotalPriceDataTable.Columns.Add("TotalPrice");
            TotalPriceDataTable.Columns.Add("TotalPaid");
            TotalPriceDataTable.Columns.Add("TotalDue");

            DataRow TotalPriceDataRow = TotalPriceDataTable.NewRow();
            TotalPriceDataRow["TotalCardServiceFee"] = WJNReservation.GetTotalCardFeeByReservationId(ReservationId, CurrencyId).ToString("0.00");
            TotalPriceDataRow["TotalPrice"] = WJNReservation.GetTotalToPayByReservationId(ReservationId, CurrencyId, 100).ToString("0.00");
            TotalPriceDataRow["TotalPaid"] = WJNReservation.GetTotalPaidByReservationId(ReservationId, CurrencyId).ToString("0.00");
            TotalPriceDataRow["TotalDue"] = WJNReservation.GetTotalDueByReservationId(ReservationId, CurrencyId).ToString("0.00");
            TotalPriceDataTable.Rows.Add(TotalPriceDataRow);

            reportViewer.LocalReport.DataSources.Add(new ReportDataSource("DataSet7",
                                                                TotalPriceDataTable));

            reportViewer.LocalReport.Refresh();
            Warning[] warnings;
            string[] streamids;
            string mimeType;
            string encoding;
            string extension;

            string deviceInfo =
           "<DeviceInfo>" +"  <EmbedFonts>None</EmbedFonts>" +"</DeviceInfo>";

            //this is array bytes that you need
            byte[] bytes = reportViewer.LocalReport.Render(
                               "PDF", deviceInfo, out mimeType, out encoding,
                                out extension,
                               out streamids, out warnings);



            return bytes;


David

Claim BIXOLON Printer in POS.Net does nothing!

$
0
0

Hello there.

I am currently developing a POS application in WPF, I'm trying to use POS for Net 1.14.1 to comunicate with my BIXOLON SRP-350plusIII printer without success.

I have installed the OPOS driver given by BIXOLON and configured the printer. With the OPOS utility I can print test pages, also I have used the Sample Application -> TestApp included in the SDK for POS Net and everything works fine.

I don't know why in my WPF app I can't connecto to the printer, the problem itself is at the momment of Claiming the device, in this line the app just does nothing, no exception, nothing just stills and all of a sudden it stops the debugging and I have to re run the application.

This is the code that I am using:

private void Print()
        {
            PosExplorer posExplorer = new PosExplorer();
            DeviceInfo deviceInfo = null;
            PosPrinter posPrinter = null;

            string test = "test print 1\n";

            try
            {
                deviceInfo = posExplorer.GetDevice(DeviceType.PosPrinter, "PosPrinterTest");
                posPrinter = (PosPrinter)posExplorer.CreateInstance(deviceInfo);
            }
            catch (Exception exception)
            {
                throw exception;
            }

            posPrinter.Open();
            posPrinter.Claim(1000); // Here just hangs and does nothing
            
            if (posPrinter.Claimed)
            {
                posPrinter.AsyncMode = false;
                posPrinter.DeviceEnabled = true;
                posPrinter.PrintNormal(PrinterStation.Receipt, test);

                posPrinter.DeviceEnabled = false;
                posPrinter.Release();
                posPrinter.Close();
            }
        }
Anyone knows what the problem might be?, as I told you.. I have already tested the printer in the OPOS utility by BIXOLON and in the TestApp in the SDK for POS Net, everything works fine.

Or anyone knows another way to print Sale Tickets?

Regards.

SQLite failing to load - Timestamp of the IL assembly does not match record in .aux file

$
0
0

Hi all;

My app references sqlite3.dll and upon loading (it's a Word COM based AddIn written in C#) I am getting the following error:

WRN: Timestamp of the IL assembly does not match record in .aux file. Loading IL to compare signature.
LOG: Start validating all the dependencies.
LOG: [Level 1]Start validating native image dependency mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
Rejecting native image because native image dependency C:\WINDOWS\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll had a different identity than expected

Why am I getting this problem? The code runs fime under the VisualStudio debugger.

I am using: NuGet: System.Data.SQLite.Core by SQLite Development Team version: 1.0.108 Description: The official SQLite database engine for both x86 and x64 along with the ADO.NET provider.

thanks - dave

Full log output from fuslogvw:

*** Assembly Binder Log Entry  (9/19/2018 @ 2:14:31 PM) ***

The operation failed.
Bind result: hr = 0x80004005. Unspecified error

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable  C:\Program Files\Microsoft Office\root\Office16\WINWORD.EXE
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: DisplayName = System.Data.SQLite, Version=1.0.108.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139
 (Fully-specified)
LOG: Appbase = file:///C:/Program Files/Windward Studios/Windward Report Designer/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = NULL
Calling assembly : (Unknown).
===
WRN: Timestamp of the IL assembly does not match record in .aux file. Loading IL to compare signature.
LOG: Start validating all the dependencies.
LOG: [Level 1]Start validating native image dependency mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
Rejecting native image because native image dependency C:\WINDOWS\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll had a different identity than expected

*** Assembly Binder Log Entry  (9/19/2018 @ 2:14:31 PM) ***

The operation was successful.
Bind result: hr = 0x1. Incorrect function.

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable  C:\Program Files\Microsoft Office\root\Office16\WINWORD.EXE
--- A detailed error log follows. 

BEGIN : Native image bind.
  WRN: Timestamp of the IL assembly does not match record in .aux file. Loading IL to compare signature.
  LOG: Start validating all the dependencies.
  LOG: [Level 1]Start validating native image dependency mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
  Dependency name: mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
END   : Incorrect function. (Exception from HRESULT: 0x00000001 (S_FALSE))

*** Assembly Binder Log Entry  (9/19/2018 @ 2:14:31 PM) ***

The operation failed.
Bind result: hr = 0x80004005. Unspecified error

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable  C:\Program Files\Microsoft Office\root\Office16\WINWORD.EXE
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: DisplayName = System.Data.SQLite, Version=1.0.108.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139
 (Fully-specified)
LOG: Appbase = file:///C:/Program Files/Windward Studios/Windward Report Designer/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = NULL
Calling assembly : (Unknown).
===
WRN: Timestamp of the IL assembly does not match record in .aux file. Loading IL to compare signature.
LOG: Start validating all the dependencies.
LOG: [Level 1]Start validating native image dependency mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
Rejecting native image because native image dependency C:\WINDOWS\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll had a different identity than expected
WRN: No matching native image found.


What we did for the last 6 months - Made the world's coolest reporting & docgen system even more amazing

Wrong path returned by Environment.GetFolderPath(Environment.SpecialFolder.ApplicationFolder) on IIS6

$
0
0

On my test machine running (Windows XP, IIS5.1) the following code executed within a C# .NET WebService (.SVC) under a custom process identity (using machine.config to specify the user)

Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

correctly returns

  c:\Documents and Settings\myUserName\Application Data

However, on (Terminal Services) Windows 2003 machine running IIS6 and executing the same code but now usingApplicationPool to specify the same process identity the method returns:

c:\Documents and Settings\Default User\Application Data

Things I have checked while running on the TS/IIS6 machine:

  • myUserName belongs to the group IIS_WPG (even tried Admin)
  • a call to Environment.UserName correctly returns myUserName
  • a call to Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); also returns a 'Default User' path, likewise withDesktopDirectory
  • logged on as myUserName and ensured that C:\Documents and settings\myUserName exists
  • running the exact same code in a .net application on the Windows 2003 box, this works and returns the correct path.

I am baffled, it only occurs when runing under IIS6. It is almost like it thinks that the call is coming from Network Service or Local System users and it is not checking the Identity running the Application Pool.

Incidentally when I look at Procmon and watch a C++ application that is called from the webservice it has no such problem reading and writing to C:\Documents and settings\myUserName\ApplicatonData, it does not seem to have a problem, perhaps it builds the path differently.

I am starting to think this might be a bug in .NET, is this possible?

Thanks.

Tom Deloford


 

 

 


Any Solution to move file from a Windows CE device to a PC share folder via wifi

$
0
0

Dear sir

as per subject, I want to movie files from a Windows CE device to a PC share folder via wifi once file create at Windows CE device, is there any solution?

Please advise.

Best regards,

KKTam

Vertical alignment of multiple charts

$
0
0

Hello,

 

We have multiple charts dynamically added to the page. We have a problem with the alignment of the charts. The alignment issue is due to the varied character length of the categories displayed in the X axis.

 

We would like to display the charts vertically equal.

 

Could you suggest how to achieve this with multiple chart controls?

PrivateFontCollection freezes the application and return Error in 'w3wp.exe'

$
0
0

We are creating multiple charts as custom web control dynamically, using the below code. If use system font like 'Arial' (installed font), it creates charts well. But we need to load the font from file, for this we are using PrivateFontCollection.

The Code is:

protected override
void CreateChildControls()                         {                                     Font font;                                     string strFontFile = @"c:\temp\Source sans
pro.ttf";                                     using(PrivateFontCollection fonts = new
PrivateFontCollection())                                     {                                                 fonts.AddFontFile(strFontFile);                                                 FontFamily fontFamily = new
FontFamily(fonts.Families.FirstOrDefault()?.Name, fonts);                                                                                                  font = new Font(fontFamily, 8);                                     }                                     _chart = new
System.Web.UI.DataVisualization.Charting.Chart();                                     // Chart legent creation                                     Legend legend = new Legend                                                    {                                                                BackColor = Color.Transparent,                                                                BorderColor = Color.Transparent,                                                                LegendStyle = this.LegendStyle,                                                                Docking = this.Docking,                                                                Font = font,                                                                TextWrapThreshold = this.LegendTextWrapThreshold                                                    };                                     _chart.Legends.Add(legend);                                     this.Controls.Add(_chart);                         }




We tried to dispose the 'PrivateFontCollection' still we have these errors. But this error doesn't happenfrequently.

Please suggest, how do we use 'PrivateFontCollection' in ASP custom webcontrol? 

Thanks

Unkown node in applicationHost.config of IIS. Leaving website and app pool in unstable condition

$
0
0

Please help us out in understanding what this node in the applicationHost.config mean:

Basically we need to know what are these property ids? I guess they are leaving the website in an unstable condition and most probably corrupting the bindings. 

<customMetadata>
            <key path="LM/W3SVC">
                <property id="130001" dataType="String" userType="2" attributes="Inherit" value="BITS-Sessions" />
                <property id="130002" dataType="String" userType="2" attributes="Inherit" value="18446744073709551615" />
                <property id="130003" dataType="DWord" userType="2" attributes="Inherit" value="1209600" />
                <property id="130004" dataType="DWord" userType="2" attributes="Inherit" value="0" />
                <property id="130005" dataType="String" userType="2" attributes="Inherit" value="" />
                <property id="130007" dataType="String" userType="2" attributes="Inherit" value="" />
                <property id="130008" dataType="DWord" userType="2" attributes="Inherit" value="86400" />
                <property id="130010" dataType="DWord" userType="2" attributes="Inherit" value="0" />
                <property id="130011" dataType="DWord" userType="2" attributes="Inherit" value="1" />
                <property id="130012" dataType="DWord" userType="2" attributes="Inherit" value="12" />
                <property id="130013" dataType="DWord" userType="2" attributes="Inherit" value="1" />
                <property id="130014" dataType="DWord" userType="2" attributes="Inherit" value="0" />
                <property id="130015" dataType="DWord" userType="2" attributes="Inherit" value="0" />
                <property id="130016" dataType="DWord" userType="2" attributes="Inherit" value="0" />
                <property id="130017" dataType="DWord" userType="2" attributes="Inherit" value="50" />
                <property id="130018" dataType="DWord" userType="2" attributes="Inherit" value="0" />
                <property id="2073" dataType="MultiSZ" userType="1" attributes="Inherit" value="C:\windows\system32\bitssrv.dll&#xA;" />
            </key>
            <key path="LM/W3SVC/INFO">
                <property id="4012" dataType="String" userType="1" attributes="Inherit" value="NCSA Common Log File Format,Microsoft IIS Log File Format,W3C Extended Log File Format,ODBC Logging" />
                <property id="2120" dataType="MultiSZ" userType="1" attributes="None" value="400,0,,,0&#xA;" />
            </key>
        </customMetadata>

cannot change font or color of text

$
0
0
cannot change font or color of text in writing email in windows 8.1. Tried changing to HTML in MSN "help" but there is no response

Does ListCollectionView.CustomSort use a stable sort?

$
0
0

I sort a list in xaml using a ListCollectionView and an IComparer, and in another location in C# I need to sort in the exact same way, using the same Comparer, so the sort needs to be stable.

This sort is unstable:

myCollectionCopy = myCollection.ToList();
myCollectionCopy.Sort(myComparer);

This sort is stable:

myCollection.OrderBy(x => x.MyProperty, myComparer)

But what I can't figure out from the documentation is if ListCollectionView uses a stable sort when setting

myListCollectionView.CustomSort = myComparer;

When looking at the source code of ListCollectionView, it seems that both the return value of ICompare.Compare and also the index of the (source? listview?)collection is used (the comparer seems to be stored in the ActiveComparer property). So it could be a stable sort but I'm not sure just by looking at this code.

See also the discussion on this forum with title (I'm not allowed to post urls): 'Stable sort using List<T>'


single.Epsilon isn't.

$
0
0

The value reported by float.Epsilon isn't actually Epsilon.

According to documentation (and confirmed by experiment), Single.Epsilon has a value of  1.4E-45, which is the (as the documentation states) "the smallest positive Single greater than zero.".

Compare that to C where

float.h:

#define FLT_EPSILON     1.192092896e-07F        /* smallest such that 1.0+FLT_EPSILON != 1.0 */

and C++, where std::numeric_limits<float>::epsilon()  is "the difference between 1 and the smallest value greater than 1 that is representable for the data type".

<grumpy off topic aside> epsilon has special meaning within the ANSI/IEEE 754 standard for floating point arthmetic. The C# convention varies sharply from common usage and standard convention. And non-conformance with ANSI/IEEE 754 is not a small issue for a modern computer language. This is basic numeric analysis 101 stuff, and a mistake like this is pretty inexcusable. It makes me gravely concerned about the validity of the rest of the floating point implementation in .net. The C++ version of epsilon is intensely useful, but I can't honestly thing of a single use for the CLR version of epsilon. And the stated intended usage in the documentation for Single.Epsilon is just plain wrong. Single.Epsilon, as currently defined absolutely cannot be used for any reasonable version of soft floating point comparison.</grumpy off topic aside>.

So. Back to the real question. Is there a standard place in CLR where I can get the real machine epsilon (defined as the smallest float for which 1.0f+epsilon != 1.0f) for float?

 

<more grumpy off-topic aside> It's actually interesting how difficult it is to calculate FLOAT_EPSILON at runtime due to the oddities of Single and Double float operations on x86. I really don't like hard-coding this value.</more grumpy off-topic aside>

 

 

 

 

 


find and highlght on page webview

$
0
0

hi i was searching on web a lot but i couldn't find specific info of what i need :

when open chm files in windows built-in reader and try to use the the search the reader will find the results and highlight the terms in the standard web-view ,all modern browsers have this functionality and best of them is chrome android whats i notice in chrome is able to highlight exact terms even if there is newline between words ,  what i searched i found how to inject java script highlighter but i don't think browsers like chrome or internet explorer use this method so my question is there library that i can use to modify it that i can play with it by regex or some other method to make it detect newlines or match diacritic text or case sensitive and so ..

i'm using c# vs for mobile development for developing advanced search engine with lucene.net

Tfs2015 Task made on tfs

$
0
0
How can i retrieve Start-Date and End-Date made on task in tfs 2015 in c#.

How to convert .pst to .msg

$
0
0

Hi

Can anybody help me out find a solution for conversion of .pst file to .msg files

 

thanks & regards

KB

 

Web API and .NET Standard Project

$
0
0
Hello there,

Context:

I'm currently on application including many subproject based on .NET Standard (for Xamarin).

This application need to run local Web Server to expose an API (application must be callable from external to receive updated datas).

So, I have created an ASP.NET Core project permitting to make easily a WebApi and run a server (Kestrel). Problem, It's a .NET Core project and it's incompatible with Xamarin.

Objectives:

- The application must be callable from external (expose an API)

- The application must used .NET Standard Projects (compatibility with Xamarin)

- The application must run on desktop and mobile

Questions:

- Will WebAPI included in futures releases of .NET Standard ?

- Does it seems complicated to expose an API (and so, run a server) in mobile app (and not a good practice by the way) ?

- Is there any other way to do this work??

Thanks for your answers.

Microsoft TeamFoundation TestManagement Client - QueryAssociatedWorkItems not picking up all workitems

$
0
0

Hello 

I could not find the correct category for the question, its actually the service for TFS. 

I am trying to access all the work items associated with a test case in TFS pro grammatically using the Class in 

Microsoft.TeamFoundation.TestManagement.Client and method QueryAssociatedWorkItems()

But this returns only some work items associated not all, at times it does not return at all. 

I am trying to fetch all the bugs associated with the test case, but it does not pick all. 

I am using the right class? 

Viewing all 8156 articles
Browse latest View live


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