Nice3point / RevitTemplates

Templates for creating Revit add-ins
MIT License
232 stars 34 forks source link

Trouble with System.MissingMethodException #59

Open DmitryYalchik opened 1 week ago

DmitryYalchik commented 1 week ago

Debug on my PC working cool. But when i make nuke createInstaller and send to my colleague for tests. He starting and plugin is not working. Some trouble with SetImage.

Had think that's only in my project. Make new (clear) solution and application into. Same trouble.

image

DmitryYalchik commented 1 week ago

I removed adding image

.SetImage("/WallsReinforcement;component/Resources/Icons/wallsReinforcenet16.png")
.SetLargeImage("/WallsReinforcement;component/Resources/Icons/wallsReinforcenet32.png")

And all working normal

DmitryYalchik commented 1 week ago

I made my own extensions methods for adding images.

Now that's looking so: image

Type is Image and Store as System.Byte[] (WPF)

panel.AddPushButton<StartupCommand>("Армирование")
.OwnAddSmallImage(Properties.Resources.wallsReinforcenet16)
.OwnAddLargeImage(Properties.Resources.wallsReinforcenet32);

⏬⏬⏬

public static class RibbonButtonExtension
{
public static RibbonButton OwnAddSmallImage(this RibbonButton ribbonButton, byte[] image)
{
ribbonButton.Image = image.ToBitmap().ToImageSource();
return ribbonButton;
}
public static RibbonButton OwnAddLargeImage(this RibbonButton ribbonButton, byte[] image)
{
ribbonButton.LargeImage = image.ToBitmap().ToImageSource();
return ribbonButton;
}
}

⏬⏬⏬


public static class ByteArrayExtension
{
public static Bitmap ToBitmap(this byte[] data)
{
if (data == null || data.Length == 0)
{
throw new ArgumentNullException(nameof(data));
}
    using (var ms = new MemoryStream(data))
    {
        return new Bitmap(ms);
    }
}

}

```CSharp
public static class BitmapExtension
{
    public static ImageSource ToImageSource(this Bitmap bitmap)
    {
        IntPtr handle = bitmap.GetHbitmap();
        try
        {
            return Imaging.CreateBitmapSourceFromHBitmap(handle, IntPtr.Zero, Int32Rect.Empty,
                BitmapSizeOptions.FromEmptyOptions());
        }
        finally
        {
            NativeMethods.DeleteObject(handle);
        }
    }
    private static class NativeMethods
    {
        [DllImport("gdi32.dll", EntryPoint = "DeleteObject")]
        [return: MarshalAs(UnmanagedType.Bool)]
        public static extern bool DeleteObject([In] IntPtr hObject);
    }
}
Nice3point commented 1 week ago

This exception means that your colleague has a conflicting plugin installed, most likely an outdated version of RevitLookup. Try to update it or use a tool to find conflicting versions of Nice3point.Revit.Extensions library https://github.com/jeremytammik/RevitLookup/issues/269#issuecomment-2323309590

DmitryYalchik commented 1 week ago

He haven't LookUp on his Revit

Nice3point commented 1 week ago

So, use the DependenciesReport from the link above and share report here

DmitryYalchik commented 1 week ago

Good morning. If u need all text from file - can send for u

### Revit version: 2024 ###

| Dependency                                                | BimStep_Отв | WorkMode  | Citrus [BIM] | WallsReinforcement | Collaborate | ProSheets | Coordination Model | Coordination Model Interface | Application Dynamo Player For Revit | Lightbox DB extension | Lightbox UI extension | EntitlementDB | Revit Application Home | P&ID Modeler | Revit Shared Views | Link Topograhy Commands | Link Topography Parser Application |
|-----------------------------------------------------------|-------------|-----------|--------------|--------------------|-------------|-----------|--------------------|------------------------------|-------------------------------------|-----------------------|-----------------------|---------------|------------------------|--------------|--------------------|-------------------------|------------------------------------|
| Autodesk.Extensions.Json.dll                              | -              | -         | -            | -                  | 9.3.2       | -         | -                  | -                            | -                                   | -                     | -                     | -             | -                      | 10.0.0       | -                  | -                       | -                                  |
| Microsoft.Bcl.AsyncInterfaces.dll                         | -              | -         | -            | 8.0.23             | -           | -         | 4.700.20           | 4.700.20                     | -                                   | -                     | -                     | -             | -                      | -            | -                  | -                       | -                                  |
| Microsoft.Extensions.DependencyInjection.Abstractions.dll | -              | -         | -            | 8.0.1024           | -           | -         | -                  | -                            | -                                   | -                     | -                     | -             | -                      | 2.2.0        | -                  | -                       | -                                  |
| Microsoft.Extensions.DependencyInjection.dll              | -              | -         | -            | 8.0.1024           | -           | -         | -                  | -                            | -                                   | -                     | -                     | -             | -                      | 2.2.0        | -                  | -                       | -                                  |
| Microsoft.Xaml.Behaviors.dll                              | -              | 1.1.19    | -            | 1.1.39             | -           | 1.1.39    | -                  | -                            | -                                   | -                     | -                     | -             | -                      | -            | -                  | -                       | -                                  |
| Newtonsoft.Json.dll                                       | 13.0.3         | 13.0.1    | 13.0.3       | -                  | 13.0.1      | 12.0.2    | -                  | -                            | -                                   | -                     | -                     | 13.0.1        | 13.0.1                 | 13.0.1       | -                  | 13.0.1                  | 13.0.1                             |
| RestSharp.dll                                             | -              | -         | -            | -                  | -           | 106.15.0  | 106.12.0           | 106.12.0                     | -                                   | 106.12.0              | 106.12.0              | -             | -                      | -            | -                  | -                       | -                                  |
| System.Memory.dll                                         | -              | 4.6.31308 | -            | 4.6.31308          | -           | -         | -                  | -                            | -                                   | -                     | -                     | -             | -                      | 4.6.28619    | -                  | -                       | -                                  |
| System.Net.Http.Formatting.dll                            | -              | -         | -            | -                  | 5.2.61129   | 4.0.21112 | -                  | -                            | -                                   | -                     | -                     | -             | -                      | -            | -                  | -                       | -                                  |
| System.Runtime.CompilerServices.Unsafe.dll                | -              | 5.0.20    | -            | 6.0.21             | -           | -         | -                  | -                            | -                                   | -                     | -                     | -             | -                      | 4.6.28619    | -                  | -                       | -                                  |
| System.Threading.Tasks.Dataflow.dll                       | -              | -         | -            | -                  | -           | -         | -                  | -                            | 4.5.24                              | -                     | -                     | -             | -                      | -            | 4.700.19           | -                       | -                                  |
| System.Threading.Tasks.Extensions.dll                     | 4.6.24705      | 4.6.28619 | 4.6.24705    | 4.6.28619          | -           | -         | 4.6.28619          | 4.6.28619                    | -                                   | -                     | -                     | -             | -                      | -            | -                  | -                       | -                                  |
| Xceed.Wpf.Toolkit.dll                                     | -              | 4.3.0     | -            | -                  | -           | 3.4.0     | -                  | -                            | -                                   | -                     | -                     | -             | -                      | -            | -                  | -                       | -                                  |
Nice3point commented 1 week ago

@DmitryYalchik sorry for late response. Thats totally fine for your environment, no conflict. But your colleague have to run this tool and than send me his file

DmitryYalchik commented 4 days ago

No problem :) That's was his data. Now i can't make duplicate cus he is fired and his pc is cleaned