No parameterless constructor defined for this object  
Author Message
Drt62q





PostPosted: Thu Apr 21 01:27:04 CDT 2005 Top

Visual C#.Net >> No parameterless constructor defined for this object **************************************
//Load the Assembly
Assembly a = Assembly.LoadFrom(sAssembly);

//Get Types so we can Identify the Interface.
Type[] mytypes = a.GetTypes();
BindingFlags flags = (BindingFlags.NonPublic | BindingFlags.Public |
BindingFlags.Static | BindingFlags.Instance | BindingFlags.DeclaredOnly);

//Iterate through the Assembly to find Class with a Public Interface.
//****Each Assembly should only have one Public Entry Point****
//****using this method to expose that method and pass the XML data to it****

foreach (Type t in mytypes)
{
MethodInfo[] mi = t.GetMethods(flags);
Object obj = Activator.CreateInstance(t);

**************************************

I am trying to dynamically call an assembly. The Assembly name is being
pulled from a SharePoint List and in this case it is called TransformXML. I
am getting the following error when it gets to the Activator...

ERROR:
**********************************************************
*An unhandled exception of type 'System.MissingMethodException' occurred in
* *mscorlib.dll
*
*
*
*Additional information: No parameterless constructor defined for this
object *
**********************************************************



I am also including the code from the class being called.

Transform.dll
**************************************************
public class CreateTransform
{
#region Public Methods

public CreateTransform()
{
}

public CreateTransform(string sXML, Microsoft.SharePoint.SPListItem
_spListItem)
{
//System.Xml.XmlDocument xmlDoc;

Microsoft.SharePoint.SPAttachmentCollection spAttachColl =
this.GetXSLTransform(_spListItem);

this.TransformXML(sXML,spAttachColl);

}

#endregion

DotNet138  
 
 
Dmytro





PostPosted: Thu Apr 21 01:27:04 CDT 2005 Top

Visual C#.Net >> No parameterless constructor defined for this object Hi Brian,

Looks like the GetTypes method returns some type which indeed does not have
a public constructor.
You can debug your foreach loop to find out on which type the framework
chokes.

--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]


"brian c" <brian EMail@HideDomain.com> wrote in message
news:EMail@HideDomain.com...
> **************************************
> //Load the Assembly
> Assembly a = Assembly.LoadFrom(sAssembly);
>
> //Get Types so we can Identify the Interface.
> Type[] mytypes = a.GetTypes();
> BindingFlags flags = (BindingFlags.NonPublic | BindingFlags.Public |
> BindingFlags.Static | BindingFlags.Instance |
> BindingFlags.DeclaredOnly);
>
> //Iterate through the Assembly to find Class with a Public Interface.
> //****Each Assembly should only have one Public Entry Point****
> //****using this method to expose that method and pass the XML data to
> it****
>
> foreach (Type t in mytypes)
> {
> MethodInfo[] mi = t.GetMethods(flags);
> Object obj = Activator.CreateInstance(t);
>
> **************************************
>
> I am trying to dynamically call an assembly. The Assembly name is being
> pulled from a SharePoint List and in this case it is called TransformXML.
> I
> am getting the following error when it gets to the Activator...
>
> ERROR:
> **********************************************************
> *An unhandled exception of type 'System.MissingMethodException' occurred
> in
> * *mscorlib.dll
> *
> *
> *
> *Additional information: No parameterless constructor defined for this
> object *
> **********************************************************
>
>
>
> I am also including the code from the class being called.
>
> Transform.dll
> **************************************************
> public class CreateTransform
> {
> #region Public Methods
>
> public CreateTransform()
> {
> }
>
> public CreateTransform(string sXML, Microsoft.SharePoint.SPListItem
> _spListItem)
> {
> //System.Xml.XmlDocument xmlDoc;
>
> Microsoft.SharePoint.SPAttachmentCollection spAttachColl =
> this.GetXSLTransform(_spListItem);
>
> this.TransformXML(sXML,spAttachColl);
>
> }
>
> #endregion

 
 
brianc





PostPosted: Thu Apr 21 08:49:02 CDT 2005 Top

Visual C#.Net >> No parameterless constructor defined for this object I was under the impression that creating the method CreateTransform() that
contains no parameters would be considered the default contructor. Since it
does not require any parameters I am still confused as to what the problem
is. Could you please elaborate?


public class CreateTransform
{
#region Public Methods
public CreateTransform()
{
}

public CreateTransform(string sXML, Microsoft.SharePoint.SPListItem
_spListItem)
{
//System.Xml.XmlDocument xmlDoc;

Microsoft.SharePoint.SPAttachmentCollection spAttachColl =
this.GetXSLTransform(_spListItem);

this.TransformXML(sXML,spAttachColl);

}

#endregion

"Dmytro Lapshyn [MVP]" wrote:

> Hi Brian,
>
> Looks like the GetTypes method returns some type which indeed does not have
> a public constructor.
> You can debug your foreach loop to find out on which type the framework
> chokes.
>
> --
> Sincerely,
> Dmytro Lapshyn [Visual Developer - Visual C# MVP]
>
>
> "brian c" <brian EMail@HideDomain.com> wrote in message
> news:EMail@HideDomain.com...
> > **************************************
> > //Load the Assembly
> > Assembly a = Assembly.LoadFrom(sAssembly);
> >
> > //Get Types so we can Identify the Interface.
> > Type[] mytypes = a.GetTypes();
> > BindingFlags flags = (BindingFlags.NonPublic | BindingFlags.Public |
> > BindingFlags.Static | BindingFlags.Instance |
> > BindingFlags.DeclaredOnly);
> >
> > //Iterate through the Assembly to find Class with a Public Interface.
> > //****Each Assembly should only have one Public Entry Point****
> > //****using this method to expose that method and pass the XML data to
> > it****
> >
> > foreach (Type t in mytypes)
> > {
> > MethodInfo[] mi = t.GetMethods(flags);
> > Object obj = Activator.CreateInstance(t);
> >
> > **************************************
> >
> > I am trying to dynamically call an assembly. The Assembly name is being
> > pulled from a SharePoint List and in this case it is called TransformXML.
> > I
> > am getting the following error when it gets to the Activator...
> >
> > ERROR:
> > **********************************************************
> > *An unhandled exception of type 'System.MissingMethodException' occurred
> > in
> > * *mscorlib.dll
> > *
> > *
> > *
> > *Additional information: No parameterless constructor defined for this
> > object *
> > **********************************************************
> >
> >
> >
> > I am also including the code from the class being called.
> >
> > Transform.dll
> > **************************************************
> > public class CreateTransform
> > {
> > #region Public Methods
> >
> > public CreateTransform()
> > {
> > }
> >
> > public CreateTransform(string sXML, Microsoft.SharePoint.SPListItem
> > _spListItem)
> > {
> > //System.Xml.XmlDocument xmlDoc;
> >
> > Microsoft.SharePoint.SPAttachmentCollection spAttachColl =
> > this.GetXSLTransform(_spListItem);
> >
> > this.TransformXML(sXML,spAttachColl);
> >
> > }
> >
> > #endregion
>
>
 
 
Dmytro





PostPosted: Fri Apr 22 01:10:48 CDT 2005 Top

Visual C#.Net >> No parameterless constructor defined for this object The CreateTransform() method *is* a parameterless constructor. But - it is
not necessary the CreateTransform class is the culptit. That's why I suggest
that you step into the foreach loop in the debugger and see which Type t
causes CreateInstance to fail.

--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]


"brian c" <EMail@HideDomain.com> wrote in message
news:EMail@HideDomain.com...
>I was under the impression that creating the method CreateTransform() that
> contains no parameters would be considered the default contructor. Since
> it
> does not require any parameters I am still confused as to what the problem
> is. Could you please elaborate?
>
>
> public class CreateTransform
> {
> #region Public Methods
> public CreateTransform()
> {
> }
>
> public CreateTransform(string sXML, Microsoft.SharePoint.SPListItem
> _spListItem)
> {
> //System.Xml.XmlDocument xmlDoc;
>
> Microsoft.SharePoint.SPAttachmentCollection spAttachColl =
> this.GetXSLTransform(_spListItem);
>
> this.TransformXML(sXML,spAttachColl);
>
> }
>
> #endregion
>
> "Dmytro Lapshyn [MVP]" wrote:
>
>> Hi Brian,
>>
>> Looks like the GetTypes method returns some type which indeed does not
>> have
>> a public constructor.
>> You can debug your foreach loop to find out on which type the framework
>> chokes.
>>
>> --
>> Sincerely,
>> Dmytro Lapshyn [Visual Developer - Visual C# MVP]
>>
>>
>> "brian c" <brian EMail@HideDomain.com> wrote in message
>> news:EMail@HideDomain.com...
>> > **************************************
>> > //Load the Assembly
>> > Assembly a = Assembly.LoadFrom(sAssembly);
>> >
>> > //Get Types so we can Identify the Interface.
>> > Type[] mytypes = a.GetTypes();
>> > BindingFlags flags = (BindingFlags.NonPublic | BindingFlags.Public |
>> > BindingFlags.Static | BindingFlags.Instance |
>> > BindingFlags.DeclaredOnly);
>> >
>> > //Iterate through the Assembly to find Class with a Public Interface.
>> > //****Each Assembly should only have one Public Entry Point****
>> > //****using this method to expose that method and pass the XML data to
>> > it****
>> >
>> > foreach (Type t in mytypes)
>> > {
>> > MethodInfo[] mi = t.GetMethods(flags);
>> > Object obj = Activator.CreateInstance(t);
>> >
>> > **************************************
>> >
>> > I am trying to dynamically call an assembly. The Assembly name is
>> > being
>> > pulled from a SharePoint List and in this case it is called
>> > TransformXML.
>> > I
>> > am getting the following error when it gets to the Activator...
>> >
>> > ERROR:
>> > **********************************************************
>> > *An unhandled exception of type 'System.MissingMethodException'
>> > occurred
>> > in
>> > * *mscorlib.dll
>> > *
>> > *
>> > *
>> > *Additional information: No parameterless constructor defined for this
>> > object *
>> > **********************************************************
>> >
>> >
>> >
>> > I am also including the code from the class being called.
>> >
>> > Transform.dll
>> > **************************************************
>> > public class CreateTransform
>> > {
>> > #region Public Methods
>> >
>> > public CreateTransform()
>> > {
>> > }
>> >
>> > public CreateTransform(string sXML, Microsoft.SharePoint.SPListItem
>> > _spListItem)
>> > {
>> > //System.Xml.XmlDocument xmlDoc;
>> >
>> > Microsoft.SharePoint.SPAttachmentCollection spAttachColl =
>> > this.GetXSLTransform(_spListItem);
>> >
>> > this.TransformXML(sXML,spAttachColl);
>> >
>> > }
>> >
>> > #endregion
>>
>>