2

我有一个应用程序是另一个商业应用程序的插件,我的所有代码都在 .NET 4.0 中。显示特定对话框时,用户收到错误消息“动态程序集中不支持调用成员”。我对此进行了研究,发现所有问题都是在运行时或通过反射加载程序集的问题(正如错误所暗示的那样。但是,我的情况有两个奇怪的部分我无法弄清楚:

  1. 这似乎只发生在 32 位操作系统上,而不是 64 位操作系统上。
  2. 该对话框非常简单,它有 1 个枚举、几个属性和一些事件处理程序。我看不到任何地方正在调用任何应该创建它的东西。看起来错误是在调用“ShowDialog()”时引发的,但对话框中甚至没有用于显示窗口时的处理程序。

代码如下(ps 这是 WPF,所以我同时包含了 xaml 和 .vb 代码。

    Public Class Dlg_ManualActivate

        Public Enum ActivateOptions
            Manual = 0
            Skip = 1
        End Enum

        Public Property ActivationKey As String
        Public Property ActivateOption As ActivateOptions = ActivateOptions.Skip

        Public ReadOnly Property ActivationString As String
            Get
                Return "Activation Key:" & vbTab & ActivationKey & vbCrLf & "Computer ID:" & vbTab & Environment.MachineName
            End Get
        End Property

        Public Sub New(aKey As String)

            ' This call is required by the designer.
            InitializeComponent()

            ' Add any initialization after the InitializeComponent() call.
            ActivationKey = aKey
            DataContext = Me
        End Sub

        Private Sub btn_Email_Click(sender As System.Object, e As System.Windows.RoutedEventArgs)
            Dim msgString As String = "mailto:*myemail*"
            msgString += "?subject=Activation Request - Selection Master"
            msgString += "&body=Thank you for your interest in Selection Master.  Please send this email to receive your manual activation key.  "
            msgString += "Once your key is received you can paste it into the license activation dialog to activate your license.  Please do not "
            msgString += "modify the activation key or computer id or your manual activation key will not function.%0AActivation Key:%09%09" & ActivationKey & "%0A"
            msgString += "Computer ID:%09%09" & Environment.MachineName
            msgString = msgString.Replace(" ", "%20")
            Process.Start(msgString)
        End Sub

        Private Sub Btn_ManualActivation_Click(sender As System.Object, e As System.Windows.RoutedEventArgs)
            ActivateOption = ActivateOptions.Manual
            DialogResult = True
            Close()
        End Sub

        Private Sub Btn_Skip_Click(sender As System.Object, e As System.Windows.RoutedEventArgs)
            ActivateOption = ActivateOptions.Skip
            DialogResult = True
            Close()
        End Sub

        Private Sub Hyperlink_RequestNavigate(sender As System.Object, e As System.Windows.Navigation.RequestNavigateEventArgs)
            Process.Start(e.Uri.ToString)
        End Sub
    End Class

XAML 代码:

<Window x:Class="Dlg_ManualActivate"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
        Title="Selection Master | Manual Activation"
        ResizeMode="NoResize"
       Width="478"
             mc:Ignorable="d" d:DesignHeight="583" SizeToContent="Height" Icon="Images/Icon_SelectionMaster_64.png" WindowStartupLocation="CenterScreen">
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="RDStyles.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <Style TargetType="Button" BasedOn="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" >
                <Setter Property="Focusable" Value="False" />
                <Setter Property="HorizontalAlignment" Value="Stretch" />
                <Setter Property="VerticalAlignment" Value="Stretch" />
                <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                <Setter Property="VerticalContentAlignment" Value="Stretch" />
                <Setter Property="Margin" Value="8,4" />
                <Setter Property="Cursor" Value="Hand" />
                <Setter Property="Background" Value="White" />
                <Setter Property="BorderBrush" Value="Silver" />
                <Setter Property="BorderThickness" Value="1" />
            </Style>
        </ResourceDictionary>
    </Window.Resources>
    <Grid>
        <StackPanel>
            <Grid Background="{StaticResource br_Backdrop_Upper}">
                <Grid Margin="5,2">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Image Source="Images/Icon_SelectionMaster_64.png" Margin="8,5" />
                    <StackPanel Grid.Column="1">
                        <TextBlock Text="Welcome to Selection Master" FontSize="20" FontWeight="Bold" TextWrapping="Wrap" Margin="0,3" Foreground="{StaticResource br_RDBlue}" />
                        <Separator Margin="0,0,20,0" />
                        <TextBlock Name="tb_Msg" Margin="10,2,10,10" Text="Your automatic activation was not able to be processed, possibly due to security measures blocking Selection Master from connecting to the license server." TextWrapping="Wrap" />
                    </StackPanel>
                </Grid>
            </Grid>
            <Border Background="{StaticResource br_RDRed}" Margin="0" Padding="10,3">
                <TextBlock Text="Please Activate Your License by following the steps below" Foreground="White" FontWeight="Bold" />
            </Border>
            <Grid Grid.IsSharedSizeScope="True">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <TextBlock Text="Request Activation Via Email" Style="{StaticResource st_TitleText}" Margin="8,8,8,2" />
                <Separator Margin="8,-1" VerticalAlignment="Bottom" />
                <TextBlock Margin="8,3" Grid.Row="1" TextWrapping="Wrap">You may request manual activation via email by emailing the information below to registration@revolutiondesign.biz.  This information will automatically be added if you use the 'Create Email' button below, or you can manually copy it into an email editor of your choice.</TextBlock>
                <Grid Grid.Row="2">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <TextBlock Text="Activation Data" Style="{StaticResource st_TitleText}" Grid.ColumnSpan="2" Margin="8,8,8,2" />
                    <Separator Margin="8,-1" VerticalAlignment="Bottom" Grid.ColumnSpan="2" />
                    <TextBox Text="{Binding ActivationString, Mode=OneWay}" Grid.Row="1" Margin="8,8,4,4" />
                    <Button Grid.Column="1" Name="btn_Email" Click="btn_Email_Click" Grid.Row="1" Margin="4,8,8,4">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <Image Source="Images/Icon_Envelope.png" Margin="10,8,10,2" VerticalAlignment="Center" HorizontalAlignment="Center" />
                            <TextBlock Text="Create Email" Margin="5,2" Grid.Row="1" FontWeight="Bold" />
                        </Grid>
                    </Button>
                </Grid>
                <Button Grid.Row="3" Name="Btn_ManualActivation" Click="Btn_ManualActivation_Click">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <StackPanel Margin="3" Grid.Column="1">
                            <TextBlock Style="{StaticResource st_TitleText}" Text="Activate Manually" />
                            <Separator />
                            <TextBlock Text="Use this option when you have received a manual activation key from Revolution Design.  On the registration wizard that comes up, select 'Register' then switch to 'Manual Activation' and input the appropriate keys." TextWrapping="Wrap" Margin="10,0" />
                        </StackPanel>
                    </Grid>
                </Button>
                <Button Grid.Row="4" Name="Btn_Skip" Margin="8,4,8,8" Click="Btn_Skip_Click">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <StackPanel Margin="3" Grid.Column="1">
                            <TextBlock Style="{StaticResource st_TitleText}" Text="Skip to Standard Activation Options" />
                            <Separator />
                            <TextBlock Margin="10,0" Text="Use this option if you have purchased a key and wish to ignore the automatic activation data on your system." TextWrapping="Wrap" />
                        </StackPanel>
                    </Grid>
                </Button>
            </Grid>
            <Separator Style="{StaticResource st_SeparatorRed}" Margin="0,-1" />
            <TextBlock Padding="8,4" Background="{StaticResource br_Backdrop_Lower}">
                <Hyperlink RequestNavigate="Hyperlink_RequestNavigate" NavigateUri="http://www.revolutiondesign.biz/purchase.php">
                    <TextBlock Text="Purchase Selection Master" FontWeight="Bold" />
                </Hyperlink>
            </TextBlock>
        </StackPanel>
    </Grid>
    </Window>

这是他们机器上的错误堆栈图像:

错误堆栈

4

0 回答 0