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

1928 у кіно

Захаров Федір Захарович

Ель Греко