GithubHelp home page GithubHelp logo

Comments (7)

dahall avatar dahall commented on May 20, 2024

I can definitely do this for this particular structure. I have done it elsewhere in the library as constructors and would likely follow that same pattern here.

from vanara.

NN--- avatar NN--- commented on May 20, 2024

The problem is that you cannot overload empty constructor in struct, so using static method is a better way IMO.

from vanara.

chrpai avatar chrpai commented on May 20, 2024

I think this would help me also. My P/Invoke isn't that strong and I'm trying to get my feet wet with Authz API by calling AuthzEnumerateSecurityEventSources. I call it once to get back a count of 12
then initialize an array of AUTHZ_SOURCE_SCHEMA_REGISTRATION with that many elements. However I think I'm doing something wrong because when I call Marshal.SizeOf() I get an error saying it cannot be marshaled as an unmanaged structurel no meaninful size of offset can be computed. I've seen StackOverflow answers talking about making sure the struct has the attribute [StructLayout(LayoutKind.Sequential)] and looking through Vanara code it does.

from vanara.

chrpai avatar chrpai commented on May 20, 2024

I think I found what I needed in the AuthzEnumerateSecurityEventSourcesTest method but I'm not sure it's best practice to just assume 200 is big enough. I was assuming I'd have to call the API once to get the count and then allocate that many. But I don't really know this API well enough to say that for a fact.

from vanara.

dahall avatar dahall commented on May 20, 2024

I need to spend some time investigating this, but my guess is that it is an error on my part. I'm traveling this week and may not be able to validate or invalidate this very quickly.

from vanara.

dahall avatar dahall commented on May 20, 2024

@chrpai Please see the new issue I created from your last message. There is no bug and I provided and example of how to use the method without overallocating memory.

from vanara.

dahall avatar dahall commented on May 20, 2024

I'm closing this as I have been adding a static readonly Default field for most structures that require initialization of any type. I'll continue this trend as I add and update. Thanks for the push.

from vanara.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.