Skip to content

Assembly.GetEntryAssembly can be null and causes crashes. #27

Open

Description

@idvorkin

It will be null when called by native code, and this is causing my application to crash. When I remove those calls, everything works fine.

http://stackoverflow.com/questions/14165785/i-need-an-alternative-to-assembly-getentryassembly-that-never-returns-null

Activity

  1. damieng commented on Dec 11, 2014

    @damieng
    Contributor

    There are two calls to Assembly.GetEntryAssembly - do you know which one you are having problems with?

    The first is MeasurementConfiguration - this is easily avoided by instead using the constructor that takes application name and version rather than trying to automatically get it from the app assembly.

    The second is in AppDataContractSerializer which is used by the AutoMeasurement code to automatically handle serialization to the correct folder. AutoMeasurement is designed for regular managed Windows Store, Windows Phone or WinForms/WPF scenarios.

    It might help to understand why you are accessing CSharpAnalytics through native code and what you are trying to achieve. While I'm sure most of the pieces can be reused it's not an out-of-the-box scenario. One option would eb to change the AppDataContractSerializer to take the company name as an argument and either have that provided through the configuration mechanism.

  2. idvorkin commented on Dec 11, 2014

    @idvorkin
    Author

    My scenario is an outlook plugin, which is essentially a c# windows form that gets hosted in Outlook. Other then the issue I mentioned (and the few I'm sure I haven't found yet) it works like a charm.

    For Assembly.GetEntryAssembly, we're in complete agreement :)

    I worked around MeasurementConfiguration in my code, but for AppDataContractSerializer I just hacked the source to hard code a value - let me pass in a value as you find most appropriate.

  3. damieng commented on Dec 12, 2014

    @damieng
    Contributor

    Actually adding it to MeasurementConfiguration and plubming it through was a bit of a pain. Instead you can just set AppDataContractSerializer.FolderPath before using AutoMeasurement to avoid it guessing where to store the config file using Reflection. Let me know if that works for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions