YAFNET / YAFNET

🌐 YAF.NET - C# ASP.NET Forum
https://yetanotherforum.net
Apache License 2.0
515 stars 213 forks source link

Error upgrading forum #570

Closed john2014 closed 4 years ago

john2014 commented 4 years ago

I am trying to upgrade forum from old version to latest version (2.31.x). I have built custom application which used YAF controls to get data and these are giving errors. Here are those details:

  1. To get DisplayName from current logged in user, my code is:

    DisplayName = YAF.Core.UserMembershipHelper.GetDisplayNameFromID(UserMembershipHelper.GetUserIDFromProviderUserKey(UserMembershipHelper.GetUser(username).ProviderUserKey));

Error: The type or namespace name 'UserMembershipHelper' does not exist in the namespace 'YAF.Core' (are you missing an assembly reference?

  1. To get DisplayName from specific userID (retrieved from database), my code is:

    DisplayName = YAF.Core.UserMembershipHelper.GetDisplayNameFromID(userID);

Error: Same as error in #1 above

  1. To get userID of current logged-in user, my code is

UserID=YAF.Core.YafContext.Current.CurrentUserData.UserID.ToString()

Error: The type or namespace name 'YafContext' does not exist in the namespace 'YAF.Core' (are you missing an assembly reference?)

  1. To get DisplayName from current logged in user, my code is:

    DisplayName = YAF.Core.YafContext.Current.CurrentUserData.DisplayName;

Error: Same as error in #3 above

For these four lines of code, what would the equivalent line of code be? Thank you

w8tcha commented 4 years ago

YAF.Core.UserMembershipHelper is now YAF.Core.UsersRoles.UserMembershipHelper

Yafcontext is now BoardContext

john2014 commented 4 years ago

That issue is resolved. Now after upgrading YAF forum in Azure SQL Server, I have multiple issues depending on browser. I ran the install/upgrade script two times in Azure SQL Server.

In Firefox browser, when loading forum I immediately get the message

Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion'.

Stack Trace:

[SqlException (0x80131904): Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion'.] System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) +2555922 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) +5959168 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +285 System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) +4169 System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted) +255 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest) +2598 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry) +1483 System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry) +374 System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +286 System.Web.Util.SecUtility.CheckSchemaVersion(ProviderBase provider, SqlConnection connection, String[] features, String version, Int32& schemaVersionCheck) +392 System.Web.Security.SqlMembershipProvider.CheckSchemaVersion(SqlConnection connection) +86 System.Web.Security.SqlMembershipProvider.GetUser(String username, Boolean userIsOnline) +1064 YAF.Core.UsersRoles.UserMembershipHelper.GetUser(String username, Boolean updateOnlineStatus) +61 YAF.Core.UsersRoles.UserMembershipHelper.GetUser(Boolean updateOnlineStatus) +184 YAF.Core.BoardContext.get_User() +22 YAF.Core.BoardContext.InitUserAndPage() +62 YAF.Core.UserPageBase.get_Page() +128 YAF.Core.UserPageBase.PageValueAsInt(String field) +18 YAF.Core.BasePages.ForumPageBase.OnError(EventArgs e) +306 System.Web.UI.Page.HandleError(Exception e) +84 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6560 System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +245 System.Web.UI.Page.ProcessRequest() +72 System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +22 System.Web.UI.Page.ProcessRequest(HttpContext context) +58 ASP.discuss_default_aspx.ProcessRequest(HttpContext context) in d:\local\Temporary ASP.NET Files\root\d241c3ca\f1348f5e\App_Web_jtzauwhu.3.cs:0 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +188 System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +48 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +71

w8tcha commented 4 years ago

That issue is resolved. Now after upgrading YAF forum in Azure SQL Server, I have multiple issues depending on browser. I ran the install/upgrade script two times in Azure SQL Server.

Which Membership provider are you using? under azure you cant use the YAF Provider, only the standard AspNetSqlMembershipProvider can be used.

john2014 commented 4 years ago

I am using the AspNetSqlMembershipProvider provide under Azure SQL.

w8tcha commented 4 years ago

Please dont post multple issues in one issue report! create separte issues for issues otherwise its impossbile to follow the issues

john2014 commented 4 years ago

Please dont post multple issues in one issue report! create separte issues for issues otherwise its impossbile to follow the issues

Depending on browser, the issue I am seeing changes. Hence I posted two issues for two browsers. These issues occur immediately after upgrading forum.

I think the root cause if this issue

Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion'.

How do I go about fixing it? I already ran install script twice.

w8tcha commented 4 years ago

How do I go about fixing it? I already ran install script twice.

Sorry i cant help you much about this. I cant use azure anymore.

The only possible solution i found was here.. https://stackoverflow.com/questions/36413674/azure-could-not-find-stored-procedure-dbo-aspnet-checkschemaversion

john2014 commented 4 years ago

That command can only be run by logging into C: drive of SQL server. Obviusly microsoft does not allow us to run any command on sql server C: drive where the actual system files are located.

Azure provides a free unlimited app service (F1 instance). Here is the link: https://azure.microsoft.com/en-us/pricing/details/app-service/windows/

For AZURE sql service, you can use the basic instance: https://azure.microsoft.com/en-us/pricing/details/sql-database/single/

You can get 12 months of free access to Azure sql database. Select purchase model as DTU (instead of vCore). Price for that is $0.0068/hour or $5/month (if you use it for entire month).

Another option is I can send my login details for azure SQL server to you. Would that work?

john2014 commented 4 years ago

I forgot to mention: I can create the missing store procedure in sql server. Could you kindly tell me what code to execute to create stored procedure 'dbo.aspnet_CheckSchemaVersion'.

w8tcha commented 4 years ago

Looking at the install scripts. the membership scripts for azure are only executed on a new install. Did you install a new version or did you upgrade from a previous version?

w8tcha commented 4 years ago

That command can only be run by logging into C: drive of SQL server. Obviusly microsoft does not allow us to run any command on sql server C: drive where the actual system files are located.

Azure provides a free unlimited app service (F1 instance). Here is the link: https://azure.microsoft.com/en-us/pricing/details/app-service/windows/

For AZURE sql service, you can use the basic instance: https://azure.microsoft.com/en-us/pricing/details/sql-database/single/

You can get 12 months of free access to Azure sql database. Select purchase model as DTU (instead of vCore). Price for that is $0.0068/hour or $5/month (if you use it for entire month).

Another option is I can send my login details for azure SQL server to you. Would that work?

Sorry but i will never again use this criminal service again. After they stole so many money from me by error

w8tcha commented 4 years ago

you could try to run the install script manually

IF (NOT EXISTS (SELECT name
              FROM sys.objects
             WHERE (name = N'aspnet_CheckSchemaVersion')
               AND (type = 'P')))
   EXEC('CREATE PROCEDURE [dbo].aspnet_CheckSchemaVersion AS RAISERROR(''Empty aspnet_CheckSchemaVersion Procedure!!'', 16, 1) WITH SETERROR')
GO

ALTER PROCEDURE [dbo].aspnet_CheckSchemaVersion
    @Feature                   nvarchar(128),
    @CompatibleSchemaVersion   nvarchar(128)
AS
BEGIN
    IF (EXISTS( SELECT  *
                FROM    dbo.aspnet_SchemaVersions
                WHERE   Feature = LOWER( @Feature ) AND
                        CompatibleSchemaVersion = @CompatibleSchemaVersion ))
        RETURN 0

    RETURN 1
END
GO
john2014 commented 4 years ago

Looking at the install scripts. the membership scripts for azure are only executed on a new install. Did you install a new version or did you upgrade from a previous version?

I upgraded from 2.0 to 2.31.6 version.

w8tcha commented 4 years ago

Looking at the install scripts. the membership scripts for azure are only executed on a new install. Did you install a new version or did you upgrade from a previous version?

I upgraded from 2.0 to 2.31.6 version.

At the moment i can only support new installs on azure. If it is an upgrade from a old version you need to run all the azure provider scripts manually.

john2014 commented 4 years ago

Also what is the path where the azure upgrade sql scripts are located? I only find /install/mssql/install/azure/

There is no azure folder under upgrade.

w8tcha commented 4 years ago

Tha

Also what is the path where the azure upgrade sql scripts are located? I only find /install/mssql/install/azure/

There is no azure folder under upgrade.

Thats correct. because as i wrote above the membership scripts are only installed on a new install

w8tcha commented 4 years ago

The script you posted seems to currently work. I have created a clean link:

If you view console in chrome/firefox browser, you will see many javascript errors. Please have a look.

Well looks like you compiled yaf in debug mode. in that case the script files from cdn are loaded as http and not as https. Also its loads the unminified version of jquery.ForumExtensions.js (which doesent seem to exist on the server)

john2014 commented 4 years ago

Well looks like you compiled yaf in debug mode. in that case the script files from cdn are loaded as http and not as https.

Yeah, I had enabled debug mode in web.config so that I can get the actual server message. I have now turned off debug mode off. But it is still loading cdn files in http mode. I have asked server to manually rewrite http to https (on each request) so that error will go away. Can you do it so that it always loads https (whether in debug mode or not).

Also its loads the unminified version of jquery.ForumExtensions.js (which doesent seem to exist on the server)

That is because unminified version does not exists in the installation files. Hence I do not know where to get unminified version from. I have renamed " jquery.ForumExtensions.min.js" to "jquery.ForumExtensions.js" and uploaded to server. Now 404 error is not there.

But if you click login and enter random username/password and click submit; you will see more errors in browser console.

w8tcha commented 4 years ago

That is because unminified version does not exists in the installation files. Hence I do not know where to get unminified version from. I have renamed " jquery.ForumExtensions.min.js" to "jquery.ForumExtensions.js" and uploaded to server. Now 404 error is not there.

The unmodified is only needed if you are using debug mode, if you want to use debug mode then download the source files

w8tcha commented 4 years ago

Looking at the error message it still shows that there is no access to the sp mentioned above. Did you run all sql scripts manually as suggested?

john2014 commented 4 years ago

Could you tell me which specific sql scripts to run manually? There are too many sql scripts (in install and upgrade folder; in custom and azure sub folders).

Also what is dp?

w8tcha commented 4 years ago

Of course only the files from the azure folder as I wrote before.

I ment sp not dp! The stored procedure mentioned above

john2014 commented 4 years ago

Manually running the install sl code within azure folder worked. The forum is now opening.

However when I visit link /default.aspx?g=admin_admin, I get a server error YAF Error

john2014 commented 4 years ago

If you send me your email address, I will create a new app service on azure and new sql database on azure and send login details to you. You can do all testing (new installs, upgrades, etc). Once you have completed testing (in 4-5 days), I will then delete those azure resources. Would that work?

Once you post your email address here, github will send me an email with your comment. One minute after posting your email address here, you can then delete that comment. This way your email will also be secure.

w8tcha commented 4 years ago

Manually running the install sl code within azure folder worked. The forum is now opening.

However when I visit link /default.aspx?g=admin_admin, I get a server error

YAF Error

Which yaf version?

john2014 commented 4 years ago

The latest version I downloaded yesterday (2.3.1.6)

w8tcha commented 4 years ago

Looks like there is an issue, is there an entry in the yaf event log?

In the next update I put an catch handle to prevent this error

john2014 commented 4 years ago

There is no entry in the event log for this error. Which makes sense since if there was a try/catch block, it would not display this error message. It would instead log this error in the event log.

Also, I have attached the last 50 error message (since I upgraded the forum to version 2.3.1.6) EventLog.txt

w8tcha commented 4 years ago

The event log entries clearly show that you are not running the latest version. Or you don't have updated all dlls and or removed the old ones.

Also that you don't have a machine key in the web.config

john2014 commented 4 years ago

The event log entries clearly show that you are not running the latest version.

I downloaded the latest version and installed it twice. On first install, it told me there is a newer version. On second install, it said the current and new version are the same.

Or you don't have updated all dlls and or removed the old ones.

I removed the /Bin folder and recreated it from files that I downloaded on github.

Also that you don't have a machine key in the web.config

I do have a machine key. In addition, azure automatically adds it own machine key (even if we have specified it in web.config).

Could you please tell me which eventlogid shows these things missing?

w8tcha commented 4 years ago

"Source": "ASP.discuss_default_aspx", "Description": "Exception\r\nSystem.Web.HttpException (0x80004005): Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.\r\n\r\nSee http://go.microsoft.com/fwlink/?LinkID=314055 for more information. --->

john2014 commented 4 years ago

Yeah, I already found out about the machinekey in the log (easy to search). I am still not sure why it is giving that error message.

Can you tell me where to find the other two error message (older version, dll missing).

w8tcha commented 4 years ago

YAF.Core.Services.YafSendMailThreaded

first entry for example. That class doesn't exist anymore in yaf 2.31

john2014 commented 4 years ago

I am still working on this (including doing a new install). In the meanwhile, I found another bug:

From default.aspx?g=admin_restore, if you click on Delete All button, I get the following error message:

Screenshot_2020-06-15 Could not load file or assembly 'Microsoft Extensions Primitives, Version=3 1 0 0, Culture=neutral, P

I did verify that Microsoft.Extensions.Primitives exists in /Bin folder. Also there should be a try/catch block.

john2014 commented 4 years ago

In the https://github.com/YAFNET/YAFNET/releases, what is the difference between Deploy, Install, Upgrade. When should we download each option?

w8tcha commented 4 years ago

I am still working on this (including doing a new install). In the meanwhile, I found another bug:

From default.aspx?g=admin_restore, if you click on Delete All button, I get the following error message:

Screenshot_2020-06-15 Could not load file or assembly 'Microsoft Extensions Primitives, Version=3 1 0 0, Culture=neutral, P

I did verify that Microsoft.Extensions.Primitives exists in /Bin folder. Also there should be a try/catch block.

No thats not a bug, just make sure assembly is set in the web.config under assemblybinding

john2014 commented 4 years ago

In web.config, I see the following lines:

 <assemblies>
        <add assembly="netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" />
      </assemblies>

Could you tell me the exact code to add to web.config?

w8tcha commented 4 years ago

In the https://github.com/YAFNET/YAFNET/releases, what is the difference between Deploy, Install, Upgrade. When should we download each option?

Install is for new installs, upgrade is for upgrades and deploy is only used for the ms one click installer

w8tcha commented 4 years ago

In web.config, I see the following lines:

 <assemblies>
        <add assembly="netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" />
      </assemblies>

Could you tell me the exact code to add to web.config?

Look in the recommend or upgrade config. or in the wiki on how to upgrade!

</system.web>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <probing privatePath="bin;" />
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" />
        <bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="12.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Extensions.Primitives" publicKeyToken="ADB9793829DDAE60" culture="neutral"/>
        <bindingRedirect oldVersion="0.0.0.0-3.1.4.0" newVersion="3.1.4.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/>
        <bindingRedirect oldVersion="0.0.0.0-4.0.6.0" newVersion="4.0.6.0"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <system.webServer>
w8tcha commented 4 years ago

Please open new issue reports for each new issue. Otherwise its impossible to help you