| |

VerySource

 Forgot password?
 Register
Search
View: 562|Reply: 7

There is a piece of code that always reports errors!

[Copy link]

2

Threads

9

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-1-16 07:00:01
| Show all posts |Read mode
/// <summary>
/// Database access interface.
/// </ summary>
public static Interfaces.Data.IDataAccess CreateInstance ()
{
string connectionString = Reservoir.Configuration.GeneralOperator.Get ("ConnectionString");
string providerType = Reservoir.Configuration.GeneralOperator.Get ("ProviderType");

Interfaces.Data.IDataAccessFactory dataAccessFactory = (Interfaces.Data.IDataAccessFactory) Reservoir.Plugin.PluginOperator.Get ("DataAccessFactory"). CreateInstance ();
return dataAccessFactory.CreateDataAccess (connectionString, providerType);
}

This sentence:
return dataAccessFactory.CreateDataAccess (connectionString, providerType);
Reply

Use magic Report

2

Threads

9

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-1-20 02:27:01
| Show all posts
Server error in "/Reservoir.Web" application.
-------------------------------------------------- ------------------------------

Object reference is not set to an instance of the object.
Explanation: An unhandled exception occurred during the execution of the current web request. Check the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: The object reference was not set to an instance of the object.

Source error:


Line 16:
Line 17: Interfaces.Data.IDataAccessFactory dataAccessFactory = (Interfaces.Data.IDataAccessFactory) Reservoir.Plugin.PluginOperator.Get ("DataAccessFactory"). CreateInstance ();
Line 18: return dataAccessFactory.CreateDataAccess (connectionString, providerType);
Line 19:}
Line 20:}
 

Source file: d:\web\reservoir.logic\container\dataaccess.cs Line: 18

Stack trace:


[NullReferenceException: An object reference was not set to an instance of the object. ]
   Reservoir.Logic.Container.DataAccess.CreateInstance () in d:\web\reservoir.logic\container\dataaccess.cs: 18
   Reservoir.Logic.Container.NewsCategory.CreateOperator () in d:\web\reservoir.logic\container\newscategory.cs: 28
   Reservoir.Web.WebForm1..ctor () in d:\web\reservoir.web\webform1.aspx.cs: 21
   ASP.WebForm1_aspx..ctor () in c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\reservoir.web\ed4d0d83\10b44cec\1ocuembo.0.cs: 0

[TargetInvocationException: An exception occurred in the target of the call. ]
   System.RuntimeType.CreateInstanceImpl (Boolean publicOnly) +0
   System.Activator.CreateInstance (Type type, Boolean nonPublic) +66
   System.Activator.CreateInstance (Type type) +7
   System.Web.HttpRuntime.CreatePublicInstance (Type type)
   System.Web.UI.TemplateControlParser.GetCompiledInstance (String virtualPath, String inputFile, HttpContext context)

[HttpException (0x80004005): Failed to create a page of type "ASP.WebForm1_aspx". ]
   System.Web.UI.TemplateControlParser.GetCompiledInstance (String virtualPath, String inputFile, HttpContext context)
   System.Web.UI.PageParser.GetCompiledPageInstanceInternal (String virtualPath, String inputFile, HttpContext context)
   System.Web.UI.PageHandlerFactory.GetHandler (HttpContext context, String requestType, String url, String path)
   System.Web.HttpApplication.MapHttpHandler (HttpContext context, String requestType, String path, String pathTranslated, Boolean useAppConfig)
   System.Web.MapHandlerExecutionStep.System.Web.HttpApplication + IExecutionStep.Execute ()
   System.Web.HttpApplication.ExecuteStep (IExecutionStep step, Boolean&completedSynchronously)
Reply

Use magic Report

0

Threads

110

Posts

63.00

Credits

Newbie

Rank: 1

Credits
63.00

 China

Post time: 2020-1-20 12:09:01
| Show all posts
Breakpoint to see if the dataAccessFactory is empty?
Reply

Use magic Report

2

Threads

9

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-1-20 13:09:01
| Show all posts
The .dataAccessFactory upstairs is indeed empty. Then how to track it?
Reply

Use magic Report

0

Threads

10

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-1-21 19:27:01
| Show all posts
Check your code,
Interfaces.Data.IDataAccessFactory dataAccessFactory = (Interfaces.Data.IDataAccessFactory) Reservoir.Plugin.PluginOperator.Get ("DataAccessFactory"). CreateInstance ();
dataAccessFactory returns null, so call
return dataAccessFactory.CreateDataAccess (connectionString, providerType); Error.
Reply

Use magic Report

2

Threads

9

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-1-21 21:18:02
| Show all posts
I tracked it. I don't know why it returns empty, I am a novice. Can you help me debug the project?
Reply

Use magic Report

0

Threads

8

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-1-22 15:45:01
| Show all posts
Are you calling someone else's component, then you only need to know someone else's component code, or you want that component's person to tell you how to use it. If you can't see you try using Reflect to see the source code of this component.
Reply

Use magic Report

3

Threads

26

Posts

13.00

Credits

Newbie

Rank: 1

Credits
13.00

 China

Post time: 2020-1-28 02:36:02
| Show all posts
Decompile the DLL you used with Reflect
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list