Short answer: probably not.
Long answer: for your body to build immunity against something, it needs to identify it as something harmful to you. Otherwise, how would it know if this is just some random particle in your environment that it should ignore? There are molecular clues that your body uses to recognize better whether something is likely a pathogen (that means it should try to build immunity against) and those are some of the additives (known as adjuvants) present in man-made vaccines.
Also, the route of administration is also important. Things that you eat or breath in are triaged by the waldeyer ring because maybe you just ate something that is alive, but not exactly a pathogen. Dysfunctions in this process (thinking a normal protein is part of a dangerous pathogen) is believed to be one of the possible causes of allergies. Injecting it into your blood-stream often makes it more effective (but there are exceptions: polio vaccine however can be orally administered).
A nice read about this topic is this: The dichotomy of pathogens and allergens in vaccination approaches.
This is perhaps a must read on this topic: What to expect of a good vaccine and how to achieve it.
I'm not really sure what else to tell you. The process you described is a part of the manufacturing of some vaccines, so you are on the right track. But vaccines are hard to make, you can't do it for every disease and involves a lot of experimenting.