I followed the documentation on testing on the MvvmCross website. I'am able to register my mock dispatcher and everything works except when any of my view models executes ShowViewModel. This gives me a System.MissingMethodException.
My test class is a class library (.Net 4.5).
I have a WPF application, and everything works fine in there. But for some reason, my test class library gives me this problem. I've removed/reinstalled all NuGet packages, unchecked/checked all references to my PCL where the view models I'm testing are located.
1) Why am I getting this exception?
1.1) Could it be some dll that I'm missing?
2) Where is the actual concrete definition for ShowViewModel? The only reference I can find is in MxvNavigationObject, but that's an abstract class.
Is your Viewmodel class (where I hope you are trying to call it) inheriting from MvxViewModel? as that is where the ShowViewModel method is (via MvxNavigatingObject)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MvvmCross.Core.ViewModels;
namespace App1.ViewModels
{
public class MainViewModel : MvxViewModel
{
public MainViewModel()
{
ShowViewModel(typeof(SecondViewModel));
}
}
}
Related
Visual Studio 2019 new project Core, webAPI template project.
Controller file that comes with the project starts as such (I added .Net namespaces)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System.Net;
using System.Net.Http;
using System.Web;
namespace testwebapi.Controllers
{
[ApiController]
[Route("api/[controller]")]
public class WeatherForecastController : ControllerBase
{
public HttpResponseMessage Get(string gender = "All")
{
Request.CreateResponse()
}
}
}
however the .CreateRequest() does not exist. Request is (AspNetCore.Http.HttpRequest ControllerBase.Request) and I think that is wrong but I do not know how to do it correctly.
looks like I was using the wrong project type.
it does not appear to exist in the Core version of Api web. I still need to learn the difference and why that is
I'am starting on an empty template and following implemented stuffs on aspcore2 mvc template but when I tried to do using MyProject.Models the .Models does not appear only the .Controller
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Diagnostics;
using Microsoft.AspNetCore.Mvc;
using Webeu.????
namespace Webeu.Controllers
{
public class HomeController : Controller
{
}
}
Solved it by adding a new Model in Models folder. I guess that how it works(The Models folder must not be empty to do this).
I create cross-platform project Xamarin.Forms (shared) in Visual Studio 2015, add one page; and I need SHA256CryptoServiceProvider, but i have a problem:
"Error CS0246: The type or namespace name 'SHA256CryptoServiceProvider' could not be found (are you missing a using directive or an assembly reference?)"
MD5CryptoServiceProvider - working good.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Security.Cryptography;
using Xamarin.Forms;
namespace App1
{
public partial class Page1 : ContentPage
{
public Page1 ()
{
InitializeComponent ();
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
SHA256CryptoServiceProvider sha256 = new SHA256CryptoServiceProvider();
}
}
}
It is because this class... really doesn't exist. Why? Using Xamarin, you are using portable .NET which lacks some of the full .NET features. I'm afraid you need to use some external libraries like PCLCrypto to fulfill your needs, or implement it by yourself (this is what I've done when I needed hash function in my Xamarin App)
I have MVC4 RC project created with VS2010. I am not sure what happened, all of a sudden I started getting the following error:
Error 1 'System.Web.Optimization.BundleCollection' does not contain a
definition for 'RegisterTemplateBundles' and no extension method
'RegisterTemplateBundles' accepting a first argument of type
'System.Web.Optimization.BundleCollection' could be found (are you
missing a using directive or an assembly
reference?) C:\xxxx\xxxx\Global.asax.cs 40 33 xxxx
The error is comming from Application_Start():
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
BundleTable.Bundles.RegisterTemplateBundles();
}
I have the following using statements in my Global.asax.cs file:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
Any ideas????
Did you upgrade your Optimization package to RC? We removed that method and instead moved the bundle configuration into a BundleConfig.cs class that gets created by the new project/website template. It has a single static method called RegisterBundles which explicitly shows you what bundles are being registered, you should be able to call this in global.asax instead(you might have to tweak the bundles to match your existing app). The goal was to hopefully make bundle setup more transparent and easily tweaked.
I'm facing a strange type of issue.
In my VS Solution I have 3 projects.
ASP.Net App
C# Class Library (Used as my DAL and contains a EF .edmx file.
Windows Service App
The ASP.Net App can succesffully access the the EF Model and I can use either classic Linq or Lambda .First() etc. Everything works fine.
On my Windows Service App, I've added a reference to the DAL DLL , but for some reason, the Intellisense does not show up when I type in any code files in the windows service library. Example of my code below :
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
namespace alertservice
{
class AlertPolling
{
dal.applicationEntities ent;
public AlertPolling()
{
ent = new dal.applicationEntities();
ent.Queries. // <--- ZERO INTELLISENSE HAPPENING HERE.
}
public void StartPolling()
{
}
}
}
Thanks guys. I managed to fix the problem by following the comments from flipchart.
I added a reference to System.Data.Entity which fixed it. Intellisense now coming up.