Click here to Skip to main content
15,848,264 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am trying to establish a connection to InfluxDB database. After I publish my c# MVC app on IIS and run it, I get this error:

Quote:
System.IO.FileLoadException
Message : Could not load file or assembly 'netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
StackTrace : at System.Reflection.CustomAttribute._CreateCaObject(RuntimeModule pModule, IRuntimeMethodInfo pCtor, Byte** ppBlob, Byte* pEndBlob, Int32* pcNamedArgs)
at System.Reflection.CustomAttribute.CreateCaObject(RuntimeModule module, IRuntimeMethodInfo ctor, IntPtr& blob, IntPtr blobEnd, Int32& namedArgs)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeMethodInfo method, RuntimeType caType, Boolean inherit)
at DevExpress.DataAccess.ObjectBinding.ObjectMember..ctor(MemberInfo memberInfo)
at DevExpress.DataAccess.Native.ObjectBinding.ObjectDataSourceFillHelper.<>c.<getitemmemberscore>b__24_5(MemberInfo info)
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at DevExpress.DataAccess.Native.Web.ObjectDataSourceWizardService.GetMemberInfo(Type type, IObjectDataSourceMemberFilterService filterMemberService)
at DevExpress.DataAccess.Native.Web.ObjectDataSourceWizardService.GetAvailableObjectDescriptions(String context)
at lambda_method(Closure , IQueryBuilderRequestController , String )
at DevExpress.XtraReports.Web.Native.ClientControls.Services.RequestManagerBase`2.WrapWithTryCatchAction(String controllerTypeName, String methodName, String webActionName, ControllerFunc invoker, TController controller, String json)

I am not sure what netstandard.dll I need. I changed .NET Framework from 4.5.2 to 4.6.1, but I didn't get rid of the error. How could I solve this?

What I have tried:

The function which reads from database:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using InfluxDB.Client;
using InfluxDB.Client.Api.Domain;
using InfluxDB.Client.Api.Service;
using InfluxDB.Client.Core;

namespace ServerSide
{
    public class ReadInfluxDB
    {
        private readonly string Token = "TestTokenWEBICC";

        public async Task Main()
        {
            var client = new InfluxDBClient("http://localhost:8086", Token);

            var flux = "from(bucket:\"TestDB\") |> range(start: 0)";

            var queryApi = client.GetQueryApi();

            //
            // QueryData
            //
            var tables = await queryApi.QueryAsync(flux);//, "org_id"

            var id = tables[0].Records;
            var measure = tables[1].Records;
            var val = tables[3].Records;
            var time = tables[4].Records;
            var count = id.Count();

            List<Value> Values = new List<Value>();
            tables.ForEach(table =>
            {
                table.Records.ForEach(record =>
                {
                    Console.WriteLine($"{record.GetTime()}: {record.GetValueByKey("_value")}");
                });
            });

            for (int i = 0; i < count; i++)
            {
                Value _value = new Value();
                _value.DateAndTime = Convert.ToDateTime(time[i].GetTimeInDateTime());
                _value.Measure = Convert.ToString(measure[i].GetValue());
                _value.Val = Convert.ToDouble(val[i].GetValue());
                Values.Add(_value);
            }
            client.Dispose();
        }
    }

    public class Value
    {
        public DateTime DateAndTime { get; set; }
        public string Measure { get; set; }
        public double Val { get; set; }
    }
}
Posted
Updated 26-Jan-23 22:39pm

You are specifically telling it to load an assembly "netstandard" Version=2.1.0.0 and the error message is pretty specific: The located assembly's manifest definition does not match the assembly reference. Which means that the versions don't match.

Try removing all references in your project and add them back using the installed versions.
 
Share this answer
 
Comments
DrgIonuţ 27-Jan-23 3:55am    
Thanks for replying! If I remove the netstandar.dll from References, I get errors in my function. What should be this dll replaced with?
You're referencing a library or NuGet package which is build for .NET Standard 2.1; that library doesn't support any version of .NET Framework.

.NET Standard | Microsoft Learn[^]

You need to check your project's dependencies.
 
Share this answer
 
Comments
DrgIonuţ 27-Jan-23 3:58am    
Thanks for replying! According to the table from the link you provided, .NET Framework doesn't support .NET Standard 2.1. In this case what should I do to solve the error? If I remove the netstandar.dll from References, I get errors in my function. What should be this dll replaced with?
Richard Deeming 27-Jan-23 4:00am    
If you're using .NET Framework, then you need to stick to libraries that work in .NET Framework or .NET Standard 2.0 or lower.

If you want help to fix the errors, then you're going to need to tell us what the errors are.
DrgIonuţ 27-Jan-23 4:23am    
I am using .NET Framework 4.6.1. If I delete the netstandard.dll, I get the same error after publishing my app. The code is build without any error.
Richard Deeming 27-Jan-23 4:25am    
As I said, one of your references depends on .NET Standard 2.1, and will not work with .NET Framework. You need to find out which one, and replace it.
DrgIonuţ 27-Jan-23 4:40am    
Is there a list of references that depend on .NET Standard 2.1? I have many references added on my project, so it's like a lottery to guess which one(s) depends of .NET Standard 2.1.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900