Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid cast exception #248

Open
petrovicnemanja opened this issue May 10, 2023 · 4 comments
Open

Invalid cast exception #248

petrovicnemanja opened this issue May 10, 2023 · 4 comments

Comments

@petrovicnemanja
Copy link

Any idea what can cause this exception?

2023-05-10 10:33:22,631 [1] ERROR BVNetwork.NotFound.Core.Data.DataAccessBaseEx: An error occureding in the ExecuteScalar method with the following sqlSELECT *
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = 'dbo'
AND TABLE_NAME = '404Handler.Redirects'. Exception:System.InvalidCastException: Specified cast is not valid.
at BVNetwork.NotFound.Core.Data.DataAccessBaseEx.<>c__DisplayClass6_0.b__0()
2023-05-10 10:33:22,693 [1] ERROR BVNetwork.NotFound.Core.Data.DataAccessBaseEx: An error occureding in the ExecuteSQL method with the following sqlCREATE TABLE [dbo].[404Handler.Redirects](
[Id] [uniqueidentifier] NOT NULL,
[OldUrl] nvarchar NOT NULL,
[NewUrl] nvarchar NOT NULL,
[State] [int] NOT NULL,
[WildCardSkipAppend] [bit] NOT NULL,
CONSTRAINT [PK_404HandlerRedirects] PRIMARY KEY CLUSTERED ([Id] ASC) ON [PRIMARY]
) ON [PRIMARY]. Exception:System.Data.SqlClient.SqlException (0x80131904): There is already an object named '404Handler.Redirects' in the database.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at BVNetwork.NotFound.Core.Data.DataAccessBaseEx.<>c__DisplayClass5_0.b__0()
ClientConnectionId:fdcff185-5822-4a05-9579-904bbe4968f0
Error Number:2714,State:6,Class:16
ClientConnectionId before routing:de17607e-5d1f-4f3d-8d5b-1a44fe498b70
Routing Destination:cc9c0bbc1946.tr38524.westeurope1-a.worker.database.windows.net,11039
2023-05-10 10:33:22,769 [1] ERROR BVNetwork.NotFound.Core.Data.DataAccessBaseEx: An error occureding in the ExecuteScalar method with the following sqlSELECT *
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = 'dbo'
AND TABLE_NAME = '404Handler.Redirects'. Exception:System.InvalidCastException: Specified cast is not valid.
at BVNetwork.NotFound.Core.Data.DataAccessBaseEx.<>c__DisplayClass6_0.b__0()

@marisks
Copy link
Member

marisks commented May 10, 2023

It seems that something was not initialized properly from the beginning. Is this a new project or an existing one?
If new, you can delete all tables related to the 404 handler and stored procedure and try running again.

@petrovicnemanja
Copy link
Author

It's an existing project. It happens during site initialization, can't put a figure on the date it started occurring, but I noticed it recently. The handler itself works, though, was just curious if it's any cause for concern or if there are any steps I can take to investigate, or if it's a known issue.

@marisks
Copy link
Member

marisks commented May 10, 2023

Ok. Then you should check if all tables and everything else exists and has the same columns as here:
https://github.com/Geta/404handler/blob/master/src/Geta.404Handler/Core/Upgrade/Upgrader.cs

After that update version stored procedure to the latest version (if you have latest 404 handler) - 5

public const int CurrentVersion = 5;

@petrovicnemanja
Copy link
Author

We are on BVN.404Handler 11.2.3, I will check if we can upgrade to the latest - 11.4.0 and Geta.404Handler 1.2.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants