c sharp type pattern causes compiler error2019 Community Moderator ElectionPublished .Net-Core App won't rundocket build fails with The current .NET SDK does not support targeting .NET Core 2.1Target .Netcore 2.1 on MacVS Code C# extension reporting missing .NETFramework,Version v4.5Navigating to ASP.NET Core app results in “HTTP Error 502.5 - Process Failure” ErrorCode 0x80004005 : 1why .net core app create too many futex calls on linuxIt was not possible to find any compatible framework version when trying to scaffoldRunning 'dotnet publish' updates the SDK to the wrong versionWhy is Microsoft.AspNetCore.App listed under runtimes?Using Jenkins SonarQube MSBuild plugin with dotnet core on linux

Can I negotiate a patent idea for a raise, under French law?

How to recover against Snake as a heavyweight character?

Has a sovereign Communist government ever run, and conceded loss, on a fair election?

Does the US political system, in principle, allow for a no-party system?

Can multiple states demand income tax from an LLC?

Precision notation for voltmeters

Should we avoid writing fiction about historical events without extensive research?

Why is there an extra space when I type "ls" on the Desktop?

std::string vs const std::string& vs std::string_view

I've given my players a lot of magic items. Is it reasonable for me to give them harder encounters?

I am the person who abides by rules but breaks the rules . Who am I

Inorganic chemistry handbook with reaction lists

Why isn't P and P/poly trivially the same?

Too soon for a plot twist?

How to install "rounded" brake pads

How to write a chaotic neutral protagonist and prevent my readers from thinking they are evil?

If nine coins are tossed, what is the probability that the number of heads is even?

What is the oldest European royal house?

I am the light that shines in the dark

Will the concrete slab in a partially heated shed conduct a lot of heat to the unconditioned area?

Giving a talk in my old university, how prominently should I tell students my salary?

After Brexit, will the EU recognize British passports that are valid for more than ten years?

Is this Paypal Github SDK reference really a dangerous site?

Can Witch Sight see through Mirror Image?



c sharp type pattern causes compiler error



2019 Community Moderator ElectionPublished .Net-Core App won't rundocket build fails with The current .NET SDK does not support targeting .NET Core 2.1Target .Netcore 2.1 on MacVS Code C# extension reporting missing .NETFramework,Version v4.5Navigating to ASP.NET Core app results in “HTTP Error 502.5 - Process Failure” ErrorCode 0x80004005 : 1why .net core app create too many futex calls on linuxIt was not possible to find any compatible framework version when trying to scaffoldRunning 'dotnet publish' updates the SDK to the wrong versionWhy is Microsoft.AspNetCore.App listed under runtimes?Using Jenkins SonarQube MSBuild plugin with dotnet core on linux










0















I have the following catch statement:



 catch (CustomException e) when (e.InnerException is MySqlException ex && ex.Number == 1062)

// handle duplicate inserts



This never filters out the exception I need and the statement:



e.InnerException is MySqlException ex && ex.Number == 1062


Causes a compiler error when I watch it with the message: "internal error in the c# compiler" (see image below).
enter image description here



Changing this to the below works:



catch (CustomException e) when (e.InnerException is MySqlException && ((MySql.Data.MySqlClient.MySqlException)e.InnerException).Number == 1062)

// handle duplicate inserts



Can anyone tell me why the first usage does not work? this is part of the documentation found here: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/is#-type-pattern-



Here is my dotnet --info results



.NET Core SDK (reflecting any global.json):
Version: 2.1.503
Commit: 4c506e0f35

Runtime Environment:
OS Name: Windows
OS Version: 10.0.17134
OS Platform: Windows
RID: win10-x64
Base Path: C:Program Filesdotnetsdk2.1.503

Host (useful for support):
Version: 2.1.7
Commit: cca5d72d48

.NET Core SDKs installed:
2.1.202 [C:Program Filesdotnetsdk]
2.1.402 [C:Program Filesdotnetsdk]
2.1.403 [C:Program Filesdotnetsdk]
2.1.503 [C:Program Filesdotnetsdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.4 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.5 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.7 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.4 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.5 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.7 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.NETCore.App 2.0.9 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.1.4 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.1.5 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.1.7 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]









share|improve this question



















  • 1





    Most likely the adhoc compiler that the debugger is using in your IDE doesn't support pattern matching like this. Why the original statement doesn't catch your exception I don't know, can you post a full set of details about the CustomException instance you have?

    – Lasse Vågsæther Karlsen
    2 days ago











  • This is a relatively new language feature. So which language version are you using?

    – Hans Kesting
    2 days ago






  • 1





    Causes a compiler error what's the error?

    – Reniuz
    2 days ago











  • As requested, updated the question with the error message I get in the watch window.

    – Suemayah Eldursi
    2 days ago












  • Please post the exception as text and not as an image. An exception message in an image cannot be searched.

    – Chris Dunaway
    2 days ago
















0















I have the following catch statement:



 catch (CustomException e) when (e.InnerException is MySqlException ex && ex.Number == 1062)

// handle duplicate inserts



This never filters out the exception I need and the statement:



e.InnerException is MySqlException ex && ex.Number == 1062


Causes a compiler error when I watch it with the message: "internal error in the c# compiler" (see image below).
enter image description here



Changing this to the below works:



catch (CustomException e) when (e.InnerException is MySqlException && ((MySql.Data.MySqlClient.MySqlException)e.InnerException).Number == 1062)

// handle duplicate inserts



Can anyone tell me why the first usage does not work? this is part of the documentation found here: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/is#-type-pattern-



Here is my dotnet --info results



.NET Core SDK (reflecting any global.json):
Version: 2.1.503
Commit: 4c506e0f35

Runtime Environment:
OS Name: Windows
OS Version: 10.0.17134
OS Platform: Windows
RID: win10-x64
Base Path: C:Program Filesdotnetsdk2.1.503

Host (useful for support):
Version: 2.1.7
Commit: cca5d72d48

.NET Core SDKs installed:
2.1.202 [C:Program Filesdotnetsdk]
2.1.402 [C:Program Filesdotnetsdk]
2.1.403 [C:Program Filesdotnetsdk]
2.1.503 [C:Program Filesdotnetsdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.4 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.5 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.7 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.4 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.5 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.7 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.NETCore.App 2.0.9 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.1.4 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.1.5 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.1.7 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]









share|improve this question



















  • 1





    Most likely the adhoc compiler that the debugger is using in your IDE doesn't support pattern matching like this. Why the original statement doesn't catch your exception I don't know, can you post a full set of details about the CustomException instance you have?

    – Lasse Vågsæther Karlsen
    2 days ago











  • This is a relatively new language feature. So which language version are you using?

    – Hans Kesting
    2 days ago






  • 1





    Causes a compiler error what's the error?

    – Reniuz
    2 days ago











  • As requested, updated the question with the error message I get in the watch window.

    – Suemayah Eldursi
    2 days ago












  • Please post the exception as text and not as an image. An exception message in an image cannot be searched.

    – Chris Dunaway
    2 days ago














0












0








0








I have the following catch statement:



 catch (CustomException e) when (e.InnerException is MySqlException ex && ex.Number == 1062)

// handle duplicate inserts



This never filters out the exception I need and the statement:



e.InnerException is MySqlException ex && ex.Number == 1062


Causes a compiler error when I watch it with the message: "internal error in the c# compiler" (see image below).
enter image description here



Changing this to the below works:



catch (CustomException e) when (e.InnerException is MySqlException && ((MySql.Data.MySqlClient.MySqlException)e.InnerException).Number == 1062)

// handle duplicate inserts



Can anyone tell me why the first usage does not work? this is part of the documentation found here: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/is#-type-pattern-



Here is my dotnet --info results



.NET Core SDK (reflecting any global.json):
Version: 2.1.503
Commit: 4c506e0f35

Runtime Environment:
OS Name: Windows
OS Version: 10.0.17134
OS Platform: Windows
RID: win10-x64
Base Path: C:Program Filesdotnetsdk2.1.503

Host (useful for support):
Version: 2.1.7
Commit: cca5d72d48

.NET Core SDKs installed:
2.1.202 [C:Program Filesdotnetsdk]
2.1.402 [C:Program Filesdotnetsdk]
2.1.403 [C:Program Filesdotnetsdk]
2.1.503 [C:Program Filesdotnetsdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.4 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.5 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.7 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.4 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.5 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.7 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.NETCore.App 2.0.9 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.1.4 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.1.5 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.1.7 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]









share|improve this question
















I have the following catch statement:



 catch (CustomException e) when (e.InnerException is MySqlException ex && ex.Number == 1062)

// handle duplicate inserts



This never filters out the exception I need and the statement:



e.InnerException is MySqlException ex && ex.Number == 1062


Causes a compiler error when I watch it with the message: "internal error in the c# compiler" (see image below).
enter image description here



Changing this to the below works:



catch (CustomException e) when (e.InnerException is MySqlException && ((MySql.Data.MySqlClient.MySqlException)e.InnerException).Number == 1062)

// handle duplicate inserts



Can anyone tell me why the first usage does not work? this is part of the documentation found here: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/is#-type-pattern-



Here is my dotnet --info results



.NET Core SDK (reflecting any global.json):
Version: 2.1.503
Commit: 4c506e0f35

Runtime Environment:
OS Name: Windows
OS Version: 10.0.17134
OS Platform: Windows
RID: win10-x64
Base Path: C:Program Filesdotnetsdk2.1.503

Host (useful for support):
Version: 2.1.7
Commit: cca5d72d48

.NET Core SDKs installed:
2.1.202 [C:Program Filesdotnetsdk]
2.1.402 [C:Program Filesdotnetsdk]
2.1.403 [C:Program Filesdotnetsdk]
2.1.503 [C:Program Filesdotnetsdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.4 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.5 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.7 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.4 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.5 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.7 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.NETCore.App 2.0.9 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.1.4 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.1.5 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.1.7 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]






c# .net-core






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 days ago







Suemayah Eldursi

















asked 2 days ago









Suemayah EldursiSuemayah Eldursi

199621




199621







  • 1





    Most likely the adhoc compiler that the debugger is using in your IDE doesn't support pattern matching like this. Why the original statement doesn't catch your exception I don't know, can you post a full set of details about the CustomException instance you have?

    – Lasse Vågsæther Karlsen
    2 days ago











  • This is a relatively new language feature. So which language version are you using?

    – Hans Kesting
    2 days ago






  • 1





    Causes a compiler error what's the error?

    – Reniuz
    2 days ago











  • As requested, updated the question with the error message I get in the watch window.

    – Suemayah Eldursi
    2 days ago












  • Please post the exception as text and not as an image. An exception message in an image cannot be searched.

    – Chris Dunaway
    2 days ago













  • 1





    Most likely the adhoc compiler that the debugger is using in your IDE doesn't support pattern matching like this. Why the original statement doesn't catch your exception I don't know, can you post a full set of details about the CustomException instance you have?

    – Lasse Vågsæther Karlsen
    2 days ago











  • This is a relatively new language feature. So which language version are you using?

    – Hans Kesting
    2 days ago






  • 1





    Causes a compiler error what's the error?

    – Reniuz
    2 days ago











  • As requested, updated the question with the error message I get in the watch window.

    – Suemayah Eldursi
    2 days ago












  • Please post the exception as text and not as an image. An exception message in an image cannot be searched.

    – Chris Dunaway
    2 days ago








1




1





Most likely the adhoc compiler that the debugger is using in your IDE doesn't support pattern matching like this. Why the original statement doesn't catch your exception I don't know, can you post a full set of details about the CustomException instance you have?

– Lasse Vågsæther Karlsen
2 days ago





Most likely the adhoc compiler that the debugger is using in your IDE doesn't support pattern matching like this. Why the original statement doesn't catch your exception I don't know, can you post a full set of details about the CustomException instance you have?

– Lasse Vågsæther Karlsen
2 days ago













This is a relatively new language feature. So which language version are you using?

– Hans Kesting
2 days ago





This is a relatively new language feature. So which language version are you using?

– Hans Kesting
2 days ago




1




1





Causes a compiler error what's the error?

– Reniuz
2 days ago





Causes a compiler error what's the error?

– Reniuz
2 days ago













As requested, updated the question with the error message I get in the watch window.

– Suemayah Eldursi
2 days ago






As requested, updated the question with the error message I get in the watch window.

– Suemayah Eldursi
2 days ago














Please post the exception as text and not as an image. An exception message in an image cannot be searched.

– Chris Dunaway
2 days ago






Please post the exception as text and not as an image. An exception message in an image cannot be searched.

– Chris Dunaway
2 days ago













0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55023385%2fc-sharp-type-pattern-causes-compiler-error%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55023385%2fc-sharp-type-pattern-causes-compiler-error%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved