标签: runtimeexception

Autofac maui,Autofac.Core.Activators.Reflection.NoConstructorsFoundException:'找不到类型'xxx.Resource+Xml'的可访问构造函数

所以我正在学习 xamarin 表单课程,但我正在对其进行调整以与 .net Maui 一起使用。到目前为止,它是一个基本的应用程序,仅构建了弹出外壳。

作者使用的是 autofac,我以前从未听说过或使用过。我按照示例进行操作并得到运行时异常:

Autofac.Core.Activators.Reflection.NoConstructorsFoundException:“找不到类型‘MauiApp4.Resource+Xml’的可访问构造函数。”

我不知道这意味着什么,也不知道如何继续:叹息

(我认为它试图说它无法访问某些东西?我也怀疑与 IContainer 有关?)

哦它

当我尝试在 Visual Studio 2022 社区版的 Android Pixel 5.0 API 30 Android 模拟器上构建和运行应用程序时,会发生这种情况。

它似乎在 Container = builder.Build(); 行崩溃

Autofac使用nuget加载,版本为6.3.0

我不知道我使用的是哪个版本的 .net 或 maui,但它是最新的(我如何获取此信息?)

这是当前(适用?)代码:(它也在我的 github 存储库上https://github.com/gfmoore/MauiApp4B.App/tree/master

应用程序.xaml.cs

using System.Reflection;
using Autofac;
using IContainer = Autofac.IContainer;

namespace MauiApp4;

public partial class App : Application
{
    public static IContainer Container;

    public App()
    {
      InitializeComponent();
      //class used for registration
      var builder = new ContainerBuilder();

      //scan and register all …
Run Code Online (Sandbox Code Playgroud)

.net autofac runtimeexception .net-maui

2
推荐指数
1
解决办法
2159
查看次数

在parcelable中解组很困难

这是我写入包裹的代码

public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(poiDescription);
        dest.writeString(latitude);
        dest.writeString(longitude);
        dest.writeString(placeName);
        dest.writeString(plistPath);
        dest.writeString(poiDirName);
            if (null != isMascotPresent)
                dest.writeString(isMascotPresent);
            if (null != startMascottTime)
                dest.writeInt(startMascottTime);
            if (null != mascottDuration)
                dest.writeInt(mascottDuration);
}

public PointOfInterest(Parcel source) { 
        poiDescription = source.readString();
        latitude = source.readString();
        longitude = source.readString();
        placeName = source.readString();
        plistPath = source.readString();
        poiDirName = source.readString();
        audioLinkDownload = source.readString();
        audioLinkStream = source.readString();
        poiName = source.readString();
        poiIndex = source.readInt();
        poiPaused = source.readString();
        source.readList(imageList, null);
        source.readList(durationList, null);
        if (null != isMascotPresent)
            isMascotPresent = source.readString();
        if (null …
Run Code Online (Sandbox Code Playgroud)

android unmarshalling parcelable runtimeexception

1
推荐指数
1
解决办法
6141
查看次数

无法实现扩展的TextView

我刚刚通过Chase找到了AutoResizeTextView

自动缩放TextView文本以适应界限

但我无法让它运行起来.

AutoResizeTextView monologTextView;
monologTextView = (AutoResizeTextView) findViewById(R.id.dialogText);
Run Code Online (Sandbox Code Playgroud)

XML:

 <AutoResizeTextView
                android:id="@+id/dialogText"
                style="@style/monologText"
                android:layout_width="fill_parent"
                android:layout_height="100dp"
                android:layout_alignParentBottom="true"
                android:layout_alignParentLeft="true"
                android:ellipsize="none"
                android:singleLine="true"
                 />
Run Code Online (Sandbox Code Playgroud)

导致android.view.InflateException.

Binary XML file line #44: Error inflating class AutoResizeTextView
Run Code Online (Sandbox Code Playgroud)

当我将XML更改为TextView时

<TextView
                android:id="@+id/dialogText"
                style="@style/monologText"
                android:layout_width="fill_parent"
                android:layout_height="100dp"
                android:layout_alignParentBottom="true"
                android:layout_alignParentLeft="true"
                android:ellipsize="none"
                android:singleLine="true"
                 />
Run Code Online (Sandbox Code Playgroud)

我收到以下运行时异常:

android.widget.TextView无法强制转换为com.gootsproject.AutoResizeTextView

如何实现扩展的textView?

android extending runtimeexception

1
推荐指数
1
解决办法
646
查看次数

readBooleanArray抛出RuntimeException(“坏的数组长度”)

我知道可包裹物是隐藏的秘密,但现在我不认为我需要了解它们。

这是我之前的代码:

...
parcel.writeBooleanArray(new boolean[]{booleanValue1, booleanValue2, booleanValue3});
....

boolean[] booleans = new boolean[3];
in.readBooleanArray(booleans);
...
Run Code Online (Sandbox Code Playgroud)

不知何故,它无法在除我之外的许多设备上工作,所以我无法重现它。然后我决定将其更改为:

        ...
    parcel.writeBooleanArray(new boolean[]{booleanValue1});
    parcel.writeBooleanArray(new boolean[]{booleanValue2});
    parcel.writeBooleanArray(new boolean[]{booleanValue3});
        ...

    boolean[] booleans1 = new boolean[1];
    boolean[] booleans2 = new boolean[1];
    boolean[] booleans3 = new boolean[1];
    in.readBooleanArray(booleans1);
    in.readBooleanArray(booleans2); // it crashes here
    in.readBooleanArray(booleans3);
        ....
Run Code Online (Sandbox Code Playgroud)

包裹的源代码:

public final void readBooleanArray(boolean[] val) {
    int N = readInt();
    if (N == val.length) {
        for (int i=0; i<N; i++) {
            val[i] = readInt() != 0;
        }
    } else {
        throw new …
Run Code Online (Sandbox Code Playgroud)

android boolean parcelable runtimeexception

1
推荐指数
1
解决办法
3250
查看次数

C#Activator.CreateInstance错误

主班..

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1{
    class Program{
        static void Main(string[] args){
            string className = "Demo";
            string namespaceName = "ConsoleApplication1";
            var myObj = Activator.CreateInstance(namespaceName, className);
            Console.Read();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

其他课....

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1{
    class Demo{
        public void printClassName() {
            Console.WriteLine("Demo");
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

这个简单的程序在运行时出现错误

var myObj = Activator.CreateInstance(namespaceName, className); 线。

System.TypeLoadException {"Could not load type 'Demo' from assembly 'ConsoleApplication1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.":"Demo"}
Run Code Online (Sandbox Code Playgroud)

请帮助我解决此错误!

c# runtimeexception

1
推荐指数
1
解决办法
1646
查看次数

跟踪NullPointerExceptions的最佳方法是什么?

我现在有一些这样的例外,我总是在努力解决它们,所以任何有关如何解决它们的指南或建议都会很好,而不必依赖其他人来帮助他们.目前我有一个关于如何解决它的建议将不胜感激,但从长远来看,一般建议如何追查问题的原因会更好.

class Egg extends Bee{
    protected void anotherDay() {

        eat();
        if(age>=3)
        {
            HashMap<String, Hive> thisHive = Garden.GARDEN.getHiveMap();
            Larvae larvae = new Larvae(this.health, this.age);
            thisHive.get("a").bees.set(thisHive.get("a").beeIndex, larvae);  //-------LINE 27
            //thisHive.get("a").replaceBee(larvae)   Line 27 was origionally this throwing the same exception

        }
        age++;
        System.out.println("Egg" + " age " + this.age + " health " + this.health);

    }
}

import java.util.ArrayList;

class Hive {
    protected int honey;
    protected int royalJelly;
    protected int pollen;
    public int beeIndex; // used to know what the index of bee …
Run Code Online (Sandbox Code Playgroud)

java nullpointerexception runtimeexception

1
推荐指数
1
解决办法
140
查看次数

Groovy找不到匹配的构造函数?

请注意:虽然这个问题提到了Mongo,但它肯定是一个纯粹的Groovy问题.

我的MyApp#bootstrap方法:

def bootstrap(AppConfiguration config) {
    String h = config.dbHost
    String p = config.dbPort

    println "Mongo is at: ${h}:${p}."

    dao = new MongoDao(host: h, port: p)
}
Run Code Online (Sandbox Code Playgroud)

我的MongoDao班级(片段):

class MongoDao implements BasicDao {
    String dbName
    Mongo mongo
    String host
    String port
    Morphia morphia
    Datastore datastore

    MongoDao(String host, String port) {
        this.dbName = "db_myapp"
        this.mongo = new Mongo(host, port)
        this.morphia = new Morphia()
        this.datastore = morphia.createDatastore(mongo, dbName)

        morphia.mapPackage("myappdb.common")
    }
}
Run Code Online (Sandbox Code Playgroud)

当此bootstrap()方法运行时,我得到以下异常:

Mongo is at: …
Run Code Online (Sandbox Code Playgroud)

syntax groovy mongodb runtimeexception morphia

1
推荐指数
1
解决办法
1万
查看次数

为什么我的`main()`在junit测试中没有捕获`timer`中抛出的异常?

这是我的主要方法:

public static void main(String... args) throws ClassNotFoundException {
    String[] classAndMethod = args[0].split("#");
    if (helpCmd(args)) {
        printHelpForTest(classAndMethod[1]);
        System.exit(0);
    }

    Result result = runTest(classAndMethod);
    exitIfTimeOutExceptionThrown(result);
    System.exit(result.wasSuccessful() ? 0 : 1);
}

private static void exitIfTimeOutExceptionThrown(Result result) {
    boolean isTimeOut = Iterables.filter(result.getFailures(), CodeBlockTimeOutException.class).iterator().hasNext();
    if (isTimeOut)
    {
        System.exit(2);
    }
}
Run Code Online (Sandbox Code Playgroud)

运行此junit测试:

    @Test
    public void sendSearchRequest() throws Exception {

...

        setTimeOut();

...
    }

private void setTimeOut() {
    if (criticalBlockTimeOut != null) {
        TimerTask timerTask = new TimerTask() {
            @Override
            public void run() {
                throw …
Run Code Online (Sandbox Code Playgroud)

java junit exception error-code runtimeexception

1
推荐指数
1
解决办法
100
查看次数

除以零后没有运行时错误

我正在使用Microsoft Visual C++ 2010,我有以下代码,其中我将1除以0,如您所见

#include <cstdio>

int main()
{   
   int x;
   x = 0;
   1/x;

   while (1) {
      std::printf("RUNNING!!\n");
   }
}
Run Code Online (Sandbox Code Playgroud)

并且令人惊讶的是我没有发现任何运行时错误,程序继续执行并显示RUNNING !!

所以我的问题为什么"1/x"不被认为是运行时错误,为什么程序不停止?

c++ runtime-error visual-studio-2010 visual-c++ runtimeexception

1
推荐指数
1
解决办法
600
查看次数

java.lang.RuntimeException:不支持的文字类型类org.joda.time.DateTime

我在一个使用库的项目上工作,这对我来说是很新的,尽管我在其他项目中使用它也没有任何问题。

org.joda.time.DateTime

因此,我与Scala一起工作,并在Databricks上作为项目来运行该项目。

scalaVersion:=“ 2.11.12”

异常来自的代码-根据我到目前为止的调查^^-如下:

    var lastEndTime = config.getState("some parameters")

    val timespanStart: Long = lastEndTime // last query ending time
    var timespanEnd: Long = (System.currentTimeMillis / 1000) - (60*840) // 14 hours ago

    val start = new DateTime(timespanStart * 1000)
    val end = new DateTime(timespanEnd * 1000)

    val date = DateTime.now()
Run Code Online (Sandbox Code Playgroud)

其中,getState()函数返回1483228800作为Long类型值。

编辑:我在建立数据框时使用开始和结束日期进行过滤。我将列(时间跨度类型)与这些值进行比较!

val df2= df
           .where(col("column_name").isNotNull)
           .where(col("column_name") > start &&
                  col("column_name") <= end)
Run Code Online (Sandbox Code Playgroud)

我得到的错误:

错误从用户代码中抛出:java.lang.RuntimeException:不支持的文字类型类org.joda.time.DateTime 2017-01-01T00:00:00.000Z

我不确定我是否真正理解这是怎么回事,为什么会出错,所以每种帮助都是值得欢迎的!!提前非常感谢您!!

datetime scala jodatime runtimeexception databricks

1
推荐指数
1
解决办法
306
查看次数