0

I have created an ASP.NET web application using Visual Studio 2022 and C#. I have created a separate class library using Visual Studio 2022 and C#. In this class library, I have added a Machine Learning model. I have trained the model and obtained all the required files. I am trying to deploy this model into my ASP .NET web application.

I have added a reference to the class library in the references of the ASP web project. When I am trying to predict the results from one of the Web Forms, I am getting this error

Could not load file or assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

This is the code I used to obtain the prediction results

var sampleData = new MLModel1.ModelInput()
            {
                Mood = @"happy",
                Smell = @"rosegarden",
                Place = @"mountain",
                Drink = @"mojito",
                Category = @"trending",
                Gender = @"unisex",
                Time = @"both",
                Occasion = @"special",
                Feel = @"elegant",
                Ingredientsp1 = @"woody",
                Ingredientsp2 = @"ip5",
            };

var result = MLModel1.Predict(sampleData).ToString();

I am providing the input data and calling the Predict method to get the results. The target .NET framework for the web application is 4.8. The framework for the class library is .NET 6.0.

I deployed the ML model as a console app and it worked perfectly. But I am trying to use it in my web application so that I can get input from the users using the various controls like textboxes and button and then pass the values as input to the ML model.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

0 Answers0